With the possibility of friend function, we can also define a class as a friend of the another one, granting the second class to access the private member of the first one.
class A
{
……
public :
friend class B; // class B become a friend of class A
};
class B
{
class A
{
……
public :
friend class B; // class B become a friend of class A
};
class B
{
…….
}
Tags:
Cpp