fork download
  1. #include <iostream>
  2.  
  3. namespace ns //::ns
  4. {
  5. void f() //::ns::f
  6. {
  7. std::cout << "::ns::f"<< std::endl;
  8. }
  9. namespace ns //::ns::ns
  10. {
  11. void f() //::ns::ns::f
  12. {
  13. std::cout << "::ns::ns::f"<< std::endl;
  14. }
  15. }
  16. }
  17.  
  18. using namespace ns; //::ns
  19.  
  20. int main() //::main
  21. {
  22. ::ns::f(); //::ns::f
  23. ::ns::ns::f(); //::ns::ns::f
  24. f(); //::ns::f
  25. ns::f(); //error, ambiguous
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:25: error: reference to ‘ns’ is ambiguous
prog.cpp:4: error: candidates are: namespace ns { }
prog.cpp:10: error:                 namespace ns::ns { }
stdout

Standard output is empty