Two Classes Accessing Private Data To Each Other
Sometimes private data members are needed to be accessed and used by two different classes. In that case, friend class (or friend function) can be used. Friend class can access all data members of both the classes, even private and protected data.
For that purpose, each class should be declared as friend in the other class. They should not be member of any one of the classes.
Read more about this topic: Friend Class
Famous quotes containing the words classes, private and/or data:
“Classes struggle, some classes triumph, others are eliminated. Such is history; such is the history of civilization for thousands of years.”
—Mao Zedong (18931976)
“An affair wants to spill, to share its glory with the world. No act is so private it does not seek applause.”
—John Updike (b. 1932)
“Mental health data from the 1950s on middle-aged women showed them to be a particularly distressed group, vulnerable to depression and feelings of uselessness. This isnt surprising. If society tells you that your main role is to be attractive to men and you are getting crows feet, and to be a mother to children and yours are leaving home, no wonder you are distressed.”
—Grace Baruch (20th century)