Derivedcan access protected members Basefor all instances only Derived. But objit is not an instance Derived, it is an instance Base- therefore access is denied. The following will compile fine, as it objis nowDerived
class Derived : public Base {
public:
bool operator==(const Derived& obj) const {
return myint == obj.myint;
}
};
Barry source
share