How to declare a class as a friend of another class?
- Friend class can be declared as below :
class A
{
private:
//...
public:
//...
friend class B;
}
- Here, friend class B has full access to the private data members of class A without being a member of that class.
How to declare a class as a friend of another class?
class a
{
friend class b; // with this declaration, class b can access all members of a
};