source code clone download copy to clipboard

1
2
3
4
5
6
7
8
9
10
 int x; 
      namespace A {  int x; }
      namespace B {  int x; }
      int main()
       {
        using namespace A;
        using namespace B;
         x;  // error : ambiguity between A::i & B::i
        return 0;
       }
IGludCB4OyAKICAgICAgbmFtZXNwYWNlIEEgeyAgaW50IHg7IH0KICAgICAgbmFtZXNwYWNlIEIgeyAgaW50IHg7IH0KICAgICAgaW50IG1haW4oKQogICAgICAgewogICAgICAgIHVzaW5nIG5hbWVzcGFjZSBBOwogICAgICAgIHVzaW5nIG5hbWVzcGFjZSBCOwogICAgICAgICB4OyAgLy8gZXJyb3IgOiBhbWJpZ3VpdHkgYmV0d2VlbiBBOjppICYgQjo6aQogICAgICAgIHJldHVybiAwOwogICAgICAgfQ==

prog.cpp: In function ‘int main()’:
prog.cpp:8: error: reference to ‘x’ is ambiguous
cc1plus: error: candidates are: #‘tree_list’ not supported by dump_decl#<declaration error>
prog.cpp:2: error:                 int A::x
prog.cpp:8: error: reference to ‘x’ is ambiguous
cc1plus: error: candidates are: #‘tree_list’ not supported by dump_decl#<declaration error>
prog.cpp:2: error:                 int A::x

相关文章:

  • 2021-08-18
  • 2021-08-22
  • 2021-07-24
  • 2021-12-22
  • 2022-12-23
  • 2021-04-21
  • 2021-12-13
  • 2021-04-11
猜你喜欢
  • 2021-12-27
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案