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:

    Genocide begins, however improbably, in the conviction that classes of biological distinction indisputably sanction social and political discrimination.
    Andrea Dworkin (b. 1946)

    Now different races and nationalities cherish different ideals of society that stink in each other’s nostrils with an offensiveness beyond the power of any but the most monstrous private deed.
    Rebecca West (1892–1983)

    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)