0
Making a function friend
How to make a function friend of a seprate class file ?
1 Odpowiedź
+ 1
Declare the function inside the required class as friend and define it outside of that class (but don't write "friend" keyword in the definition part). For example:
class CLASS{ //we are in the class named CLASS
......
public: //access specifier
friend the_function();//here it's declared with the
//keyword "friend".
};//now we are out of the class
the_function()//here it will be defined (no "friend"
//keyword
{ .........
//definitions
}
Hope it helps.