A few days ago I asked a question about the scope of functions defined in a class ( What scope does a function defined in a class belong to? ), And I find out that the function is in the scope of the encompassing namespace, but will not be searchable until it explicitly declared out of class (ADL exception).
Today I found some relevant statements in the C ++ standard (section 11.3):
A function can be defined in the declaration of a friend of the class if and only if the class is a non-local class (9.8), the name of the function is unqualified, and the function has a namespace scope. [Example:
class M { friend void f() { }
Such a function is implicitly inline . The friend function defined in the class is in the (lexical) scope of the class in which it is defined. A friend function defined outside a class is not (3.4.1).
We see that there are two operators associated with the scope: “has a namespace scope and “ in the (lexical) scope of the class in which it is defined . ” I am confused here. If the first one relates to my previous question ( Which scope is a function defined in a class belonging to? ), then what does the latter mean?
source share