+ 4
What is friend function
5 Answers
+ 26
For a class having a variable which is private, we cannot access it outside that class.
But when you use "friend" keyword for any function outside the class, it can access the private variable and perform the given code.
+ 8
Hey s!d can u please give me an new code
+ 7
about discored
+ 4
friend functions are operations that are conducted between two different classes accessing private members of both.
+ 2
a friend function can access all members of a class that declared the function as friend.
like so:
class CMyClass;
void dosomething(CMyClass * a_pObject)
{
// all members of a_pObject can be accessed here !
}
class CMyClass
{
friend void dosomething(CMyClass * a_pObject);
};
}