C++ Friend Question:
Download Questions PDF

What are the advantages of using friend classes?

Answer:

There are situations when private data members need to be accessed and used by 2 classes simultaneously. In these kind of situations we can introduce friend functions which have an access to the private data members of both the classes. Friend functions need to be declared as ‘friend’ in both the classes. They need not be members of either of these classes.

Download C++ Friend Interview Questions And Answers PDF

Previous QuestionNext Question
What is a friend function?Which rule will not affect the friend function?
a) private and protected members of a class cannot be accessed from outside
b) private and protected member can be accessed anywhere
c) both a & b
d) None of the mentioned