friend class

Is it possible to do like this:

class B;

class A {
friend class B
int mA;};

class B
: public A
{
B * B::getSomeThing()
}

What I want to know is, if it is possible to a son class be friend from her super class ?
Last edited on
Instead of having private class members as private (which is default), consider having them protected. That allows derived classes to access the protected members.
Last edited on
The references I looked at say yes you can make a derived class a friend of a base class but its not recommended because it weakens 'encapsulation'.
Yes of course you can use it and agreed buffbill it breaks encapsulation but it can be used to advantage in certain cases where in only a particular derived class needs to be given the access to base class private members.

And PkD do correct the syntax errors before using the code above and also use proper indentation.

-Kush
Topic archived. No new replies allowed.