How is a friend class defined in C++? 

  • By inheriting the original class. 
  • By using the friendship keyword. 
  • By prefixing the class with the friend keyword. 
  • By including the class's header file in the original class.
A friend class in C++ is a class that is given permission to access the private and protected members of another class. To declare a class as a friend of another class, the friend keyword is used before the class declaration in the original class.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *