Friend Class - Two Classes Accessing Private Data To Each Other

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:

    Intellectuals can tell themselves anything, sell themselves any bill of goods, which is why they were so often patsies for the ruling classes in nineteenth-century France and England, or twentieth-century Russia and America.
    Lillian Hellman (1907–1984)

    Ultimately Warhol’s private moral reference was to the supreme kitsch of the Catholic church.
    Allen Ginsberg (b. 1926)

    To write it, it took three months; to conceive it three minutes; to collect the data in it—all my life.
    F. Scott Fitzgerald (1896–1940)