#include <iostream> namespace a{} namespace b{} void a::foo() { std::cout << "a foo" << std::endl; } void b::foo() { std::cout << "b foo" << std::endl; } int main() { a::foo(); b::foo(); }
Standard input is empty
prog.cpp:6:13: error: ‘void a::foo()’ should have been declared inside ‘a’ prog.cpp:11:13: error: ‘void b::foo()’ should have been declared inside ‘b’ prog.cpp: In function ‘void b::foo()’: prog.cpp:11:13: error: ‘void b::foo()’ conflicts with a previous declaration prog.cpp:6:6: note: previous declaration ‘void a::foo()’ prog.cpp: In function ‘int main()’: prog.cpp:18:5: error: ‘foo’ is not a member of ‘a’ prog.cpp:18:5: note: suggested alternative: prog.cpp:6:6: note: ‘a::foo’ prog.cpp:19:5: error: ‘foo’ is not a member of ‘b’ prog.cpp:19:5: note: suggested alternative: prog.cpp:6:6: note: ‘a::foo’
Standard output is empty