+ 4

What is friend function

6th Feb 2017, 10:13 AM
SHIKHA SINGH
SHIKHA SINGH - avatar
5 odpowiedzi
+ 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.
6th Feb 2017, 10:38 AM
Frost
Frost - avatar
+ 8
Hey s!d can u please give me an new code
6th Feb 2017, 2:46 PM
Michael55555
Michael55555 - avatar
+ 7
about discored
6th Feb 2017, 3:50 PM
Michael55555
Michael55555 - avatar
+ 4
friend functions are operations that are conducted between two different classes accessing private members of both.
6th Feb 2017, 11:12 AM
Ashutosh Saraf
Ashutosh Saraf - avatar
+ 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); }; }
7th Feb 2017, 6:42 AM
Edwin Martens
Edwin Martens - avatar