Код: Выделить всё
#include
class Parent
{
public:
Parent(int arg = 0) {}
int member() const { return member_; }
private:
int member_;
};
bool operator== (const Parent& a, const Parent& b) { return a.member() == b.member(); }
class Child : private Parent
{
public:
Child(int arg = 0) : Parent(arg) {}
};
bool operator== (const Child& a, const Child& b)
{
return static_cast (a) == static_cast (b);
}
int main()
{
assert(Child(1) == Child(1));
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... nheritance
Мобильная версия