fork download
  1. #include <iostream>
  2.  
  3. namespace A
  4. {
  5. namespace
  6. {
  7. bool foo = false;
  8. }
  9.  
  10. bool foo = true;
  11.  
  12. void bar()
  13. {
  14. std::cout << foo << '\n';
  15. }
  16. }
  17.  
  18. int main()
  19. {
  20. A::bar();
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void A::bar()’:
prog.cpp:14:22: error: reference to ‘foo’ is ambiguous
         std::cout << foo << '\n';
                      ^
prog.cpp:10:10: note: candidates are: bool A::foo
     bool foo = true;
          ^
prog.cpp:7:14: note:                 bool A::{anonymous}::foo
         bool foo = false;
              ^
prog.cpp: At global scope:
prog.cpp:7:14: warning: ‘A::{anonymous}::foo’ defined but not used [-Wunused-variable]
stdout
Standard output is empty