If a friend declaration appears in a local class (
[class.local]) and the
name specified is an unqualified name, a prior declaration is looked
up without considering scopes that are outside the innermost enclosing
non-class scope
. For a friend function declaration, if there is no
prior declaration, the program is ill-formed
. For a friend class
declaration, if there is no prior declaration, the class that is
specified belongs to the innermost enclosing non-class scope, but if it is
subsequently referenced, its name is not found by name lookup
until a matching declaration is provided in the innermost enclosing
non-class scope
. [
Example 9:
class X;
void a();
void f() {
class Y;
extern void b();
class A {
friend class X;
friend class Y;
friend class Z;
friend void a();
friend void b();
friend void c();
};
X* px;
Z* pz;
}
—
end example]