Tuesday, November 2, 2010

Using Directives

The following code does not compile:

    namespace A {
       int a = 5;
       namespace B {
          int b = a;
       }
    }
    using namespace A::B;
    int c = a;
    int main() {return c;}

Because a is not in the A::B namespace. This is trying to show that just because you are using an inner namespace, it does not mean you get to see the outer one.

No comments:

Post a Comment