Forward declaring a function in a namespace inside another function in that namespace
问题 I have two source files, a.cpp and b.cpp . In a.cpp , I have a function, foo : namespace ns { void foo() { std::cout << "foo!"; } } In b.cpp , I have another function in namespace ns in which I'd like to prototype and call foo : namespace ns { void bar() { void foo(); foo(); } } While the above is syntactically valid, it leads the compiler to think that foo is in the global namespace (or at least that's what I've deduced from the linker errors I get when I do this). My first two ideas to fix