Professional Documents
Culture Documents
Friend Fun
Friend Fun
Friend Fun
&
Friend Class
Friend Function
• The private members can not be accessed
from outside the class.
• However ……. ?
Friend Function continue…
Special Characteristics:
• It is not in the scope of the class to which it
has been declared as friend.
Special Characteristics:
• Unlike member functions, it cannot access
the member names directly and has to use an
object name and dot membership operator
with each member name.
• It can be declared either in the public or
private part of a class without affecting its
meaning.
• Usually, it has objects as arguments.
Friend Function continue…
class X class Y
{ {
… …
… …
int fun1 ( ); friend int X : : fun1 ( );
… …
}; };
Friend Class continue…