fork download
  1. #include <iostream>
  2.  
  3. namespace a{}
  4. namespace b{}
  5.  
  6. void a::foo()
  7. {
  8. std::cout << "a foo" << std::endl;
  9. }
  10.  
  11. void b::foo()
  12. {
  13. std::cout << "b foo" << std::endl;
  14. }
  15.  
  16. int main()
  17. {
  18. a::foo();
  19. b::foo();
  20. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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’
stdout
Standard output is empty