不确定这是否可能,但我在嵌套命名空间的不同级别中有两个同名的类,我想让更浅的类成为更深的类的朋友。例子:
在 File1.h 中:
namespace A
{
class Foo
{
//stuff
};
}
在 File2.h 中:
namespace A
{
namespace B
{
class Foo
{
friend class A::Foo; //Visual Studio says "Error: 'Foo' is not a member of 'A'"
};
}
}
这可能吗?如果是这样,正确的语法是什么?