a friend cannot be inherited: that is, a friend of a base class may not be a friend of a subclass, and a subclass of a friend of a type may not be a friend of this type. in detail, you can look at the following two sections:
What does it mean that "friendship isn ' t inherited, transitive, or reciprocal"?
Just because I grant you friendshipAccessTo me doesn ' t automaticallygrant your kidsAccessTo me, doesn ' t automatically grant your friendsAccessTo me, and doesn ' t automatically grant meAccessTo you. I don ' t necessarily trust the kids's my friends. The privileges offriendship aren ' t inherited.DerivedClasses of afriendAren ' t necessarilyfriends. IfclassFred declares that.class Baseis afriend, classesderivedFromBaseDon ' t have any automatic specialAccessRights tofred objects. I don ' t necessarily trust the friends's my friends. The privilegesof friendship aren ' t transitive. Afriendof afriendisn ' t necessarily afriend. IfclassFred declaresclassWilma as afriend, andclassWilma declaresclassBetty as afriend,classBetty doesn ' tnecessarily have any specialAccessRights to Fred objects. Don ' t necessarily trust me simply because I declare for youfriend. The privileges of Friendship aren ' t reciprocal. IfclassFreddeclares thatclassWilma is afriend, Wilma objects have specialAccessTo Fred Objects but Fred objects does not automatically have specialAccessTo Wilma objects. (http://www.parashift.com/c++-faq-lite/friends.html)
What is inherited from the base class?
In principle, a derived class inherits every member of a base class except:
Its constructor and its destructor its operator= (), its friends (http://www.cplusplus.com/doc/tutorial/ inheritance/)