Please explain.
"Friend Function does not have the class scope, rather it depends on the original declaration and definition"
Does declaring frinds in public/private/protected make any difference?
Printable View
Please explain.
"Friend Function does not have the class scope, rather it depends on the original declaration and definition"
Does declaring frinds in public/private/protected make any difference?
Nope, no difference at all.
What about the quoted line. Please explain that too.
A friend declaration is just a declaration of friendship, the scope and lifetime of the friend itself depends on where the friend is defined:
Code:namespace Test {
// has namespace Test scope
void function1() {
}
}
// has global scope
void function2() {
}
class C {
friend void function1(); // still namespace Test scope
friend void function2(); // still global scope
};