Advantages of using friend classes
Explain the advantages of using friend classes.
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.
What are friend classes? Explain its uses with an example.
A friend class and all its member functions have access to all the private members defined within other class.
Post a Comment