How to declare a class as a friend of another class - C++

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
};
Class vs. Structure - C++
Class vs. Structure - Class has private as default access specifier.Default inheritance type is private......
How to call a base member function from derived class member function.
How to call a base member function from derived class member function....
Is it possible to overload a constructor?
Is it possible to overload a constructor? - Yes it is possible. A constructor can be overloaded to pass different arguments to the object....
Post your comment