A friend class in C++, can access the "private" and "protected" members of the class in which it is declared as a friend. On declaration of friend class all member function of the friend class become friend of the class in which the friend class was declared. Friend status is not inherited; every friendship has to be explicitly declared. Friend classes can help in improving Encapsulation if used wisely.
Read more about Friend Class: Declaration, Advantages of Using Friend Class, Two Classes Accessing Private Data To Each Other, Scope, Features, Friend and Encapsulation
Famous quotes containing the words friend and/or class:
“Overcome the Empyrean; hurl
Heaven and Earth out of their places,
That in the same calamity
Brother and brother, friend and friend,
Family and family,
City and city may contend.”
—William Butler Yeats (18651939)
“Why, since man and woman were created for each other, had He made their desires so dissimilar? Why should one class of women be able to dwell in luxurious seclusion from the trials of life, while another class performed their loathsome tasks? Surely His wisdom had not decreed that one set of women should live in degradation and in the end should perish that others might live in security, preserve their frappeed chastity, and in the end be saved.”
—Madeleine [Blair], U.S. prostitute and madam. Madeleine, ch. 10 (1919)