I am trying to inherit a subclass, which is declared as a private member of another class. Although the Friend is declared as a friend of Class, my compiler spits out the following error:
Could anyone explain to me what I am getting wrong here? BTW, the compiler I am using is gcc 4.1.2.Class.h:5: error: ‘class Class::SubClass’ is private
Friend.h:3: error: within this context
Class.h, the class with the private subclass that I am trying to inherit:
Friend.h, the class that is trying to inherit the private subclass:Code:class Class { private: class SubClass { public: void A(); }; public: friend class Friend; };
Code:#include "Class.h" class Friend: public Class::SubClass { };