We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

Explicit Qualification

Namespace members can be accessed using an explicit qualifier and the scope-resolution operator.

For example:

// explicit_qualification.cpp
int i;

namespace A
   int a, b, c;

   namespace B
      int i, j, k;

int main()
   A::B::i++;   // B's i
   ::i++;   // the global I

The statement ::i++ accesses the i that is declared in the first statement of the example. Such usage of the scope-resolution operator without a preceding qualifier invokes the global namespace.

Usage of explicit qualification might be cumbersome with longer names or in large programs. The using declaration, using directive, and namespace aliases provide more straightforward ways to reference namespace members.

For more information, see Qualified Names.