language: C++ 4.7.2 (gcc-4.7.2)
date: 457 days 2 hours ago
link:
visibility: public
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: 0.01s    memory: 2724 kB     returned value: 0

    30, 20, 10