Whats in this post?
- Background and Explanation of the code
To copy code: Click “View Source” on the right of this code snippet.
Background and Explanation of the code
The statement, friend class yyy; within the definition of class xxx informs the compiler that entire class yyy is a friend of class xxx.This means all the member function of a class yyy are the friend function of class xxx.Declaring a class yyy as a friend of a class xxx doesnot mean that class xxx is also a friend of class yyy so member functions of class xxx cant access private members of class yyy.
x = 10
y = 15