The following code compiles on MSVC:
#include <iostream>
class Bob
{
int a;
friend class Outer;
};
class Outer
{
class Inner
{
void f(Bob obj)
{
std::cout << obj.a; //OK
}
};
};
So it seems that if Outer is a friend of Bob, so is Inner, automatically. I am reading the Friends chapter of the standard and am unable to find a clause that would confirm or refute this.
Is this legal, and if so, what's the chapter and verse?