1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> int a = 10; namespace M { int a = 20; namespace N { int a = 30; void f() { int x = a; //a refers to the name inside N, same as M::N::a int y = M::a; //M::a refers to the name inside M int z = ::a; //::a refers to the name in the global namespace std::cout << x << ", "<< y << ", " << z << std::endl; //30,20,10 } } } int main() { M::N::f(); } |
-
upload with new input
-
result: Success time: 0s memory: 2896 kB returned value: 0
int a = 10; namespace M { int a = 20; namespace N { int a = 30; void f() { int x = a; //a refers to the name inside N, same as M::N::a int y = M::a; //M::a refers to the name inside M int z = ::a; //::a refers to the name in the global namespace std::cout << x << ", "<< y << ", " << z << std::endl; //30,20,10 } } } int main() { M::N::f(); } - See more at: http://ideone.com/sp28n#sthash.hxnsih6z.dpuf30, 20, 10
-
result: Success time: 0s memory: 2896 kB returned value: 0
int a = 30; namespace M { int a = 20; namespace N { int a = 30; void f() { int x = a; //a refers to the name inside N, same as M::N::a int y = M::a; //M::a refers to the name inside M int z = ::a; //::a refers to the name in the global namespace std::cout << x << ", "<< y << ", " << z << std::endl; //30,20,10 } } } int main() { M::N::f(); } - See more at: http://ideone.com/sp28n#sthash.hxnsih6z.dpuf30, 20, 10
-
result: Success time: 0s memory: 2852 kB returned value: 0
#include <iostream> int a = 5; namespace M { int a = 20; namespace N { int a = 30; void f() { int x = a; //a refers to the name inside N, same as M::N::a int y = M::a; //M::a refers to the name inside M int z = ::a; //::a refers to the name in the global namespace std::cout << x << ", "<< y << ", " << z << std::endl; //30,20,10 } } } int main() { M::N::f(); }30, 20, 10
-
result: Success time: 0.01s memory: 2724 kB returned value: 0
30, 20, 10


