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