Sponsored Links
-->

Friday, May 4, 2018

C++ TUTORIAL -78- Friend Class - YouTube
src: i.ytimg.com

A friend class in C++ can access the private and protected members of the class in which it is declared as a friend.


Video Friend class



Rationale

Friendship may allow a class to be better encapsulated by granting per-class access to parts of its API that would otherwise have to be public. This increased encapsulation comes at the cost of tighter coupling due to interdependency between the classes.


Maps Friend class



Example


Learning Objectives Pointers as dada members - ppt download
src: slideplayer.com


Properties

  • Friendships are not symmetric - if class A is a friend of class B, class B is not automatically a friend of class A.
  • Friendships are not transitive - if class A is a friend of class B, and class B is a friend of class C, class A is not automatically a friend of class C.
  • Friendships are not inherited - if class Base is a friend of class X, subclass Derived is not automatically a friend of class X; and if class X is a friend of class Base, class X is not automatically a friend of subclass Derived.

Nobody's friend - CBSE Class V English Poem - YouTube
src: i.ytimg.com


See also

  • Friend function

Fit 5: You Want to Bring a Friend to Class - The Warm Up
src: classpass.com


References


74. Example of Friend Function in C++ (Hindi) - YouTube
src: i.ytimg.com


External links

  • http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr043.htm
  • http://www.cplusplus.com/doc/tutorial/inheritance/

Source of article : Wikipedia