The using directive (C++ only)

A using directive provides access to all namespace qualifiers and the scope operator. This is accomplished by applying the using keyword to a namespace identifier.

Read syntax diagramSkip visual syntax diagram
Using directive syntax

>>-using--namespace--name--;-----------------------------------><

The name must be a previously defined namespace. The using directive may be applied at the global and local scope but not the class scope. Local scope takes precedence over global scope by hiding similar declarations with some exceptions.

For unqualified name lookup, if a scope contains a using directive that nominates a second namespace and that second namespace contains another using directive, the using directive from the second namespace acts as if it resides within the first scope.
namespace A {
  int i;
}
namespace B {
  int i;
  using namespace A;
}
void f()
{
  using namespace B;
  i = 7; // error
}
In this example, attempting to initialize i within function f() causes a compile-time error, because function f() does not know which i to call; i from namespace A, or i from namespace B.