Friend cannot inherit from private subclass
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:
Quote:
Class.h:5: error: ‘class Class::SubClass’ is private
Friend.h:3: error: within this context
Could anyone explain to me what I am getting wrong here? BTW, the compiler I am using is gcc 4.1.2.
Class.h, the class with the private subclass that I am trying to inherit:
Code:
class Class
{
private:
class SubClass
{
public:
void A();
};
public:
friend class Friend;
};
Friend.h, the class that is trying to inherit the private subclass:
Code:
#include "Class.h"
class Friend: public Class::SubClass
{
};