考虑以下代码片段:
在这种情况下,我该如何引用匿名命名空间中的内容?
void Foo() // 1
{
}
namespace
{
void Foo() // 2
{
}
}
int main()
{
Foo(); // Ambiguous.
::Foo(); // Calls the Foo in the global namespace (Foo #1).
// I'm trying to call the `Foo` that's defined in the anonymous namespace (Foo #2).
}
在这种情况下,我该如何引用匿名命名空间中的内容?
Foo
。考虑一个等效的情况:namespace A { int i; } namespace B { int i; } using namespace A; using namespace B;
。 - Georg Fritzsche