由于可以在本地类中声明友元函数,如下例所示。如果在函数定义中定义了本地类的成员,而在它之外无法访问,那么它如何用于访问本地类的成员?
void foo()
{
void bar();
class MyClass
{
int x;
friend void bar();
};
}
void bar() { // error: cannot access local class here }
int main()
{
//..
}