S
Steven T. Hatton
Can somebody explain why making T a friend of either B or C will permit the
code to compile?
class A{ protected: A(){} };
class T;
class B: protected A {protected: B(){}/*friend class T;*/};
class C: public B {public : C(){}/*friend class T;*/};
struct T { A* newA() {return new C();}};
int main() {}
This is the error I get if I do not use one of the friend declarations:
In member function ?A* T::newA()?: error: ?A? is an inaccessible base of ?C?
code to compile?
class A{ protected: A(){} };
class T;
class B: protected A {protected: B(){}/*friend class T;*/};
class C: public B {public : C(){}/*friend class T;*/};
struct T { A* newA() {return new C();}};
int main() {}
This is the error I get if I do not use one of the friend declarations:
In member function ?A* T::newA()?: error: ?A? is an inaccessible base of ?C?