Namespace member definitions (C++ only)

A namespace can define its own members within itself or externally using explicit qualification. The following is an example of a namespace defining a member internally:

namespace A {
  void b() { /* definition */ }
}

Within namespace A member void b() is defined internally.

A namespace can also define its members externally using explicit qualification on the name being defined. The entity being defined must already be declared in the namespace and the definition must appear after the point of declaration in a namespace that encloses the declaration's namespace.

The following is an example of a namespace defining a member externally:

namespace A {
  namespace B {
    void f();
  }
  void B::f() { /* defined outside of B */ }
}  

In this example, function f() is declared within namespace B and defined (outside B) in A.