Defining namespace Members

Members of a namespace may be defined within that namespace. For example:

namespace X { void f() { } }

Members of a named namespace can be defined outside the namespace in which they are declared by explicit qualification of the name being defined. However, the entity being defined must already be declared in the namespace. In addition, the definition must appear after the point of declaration in a namespace that encloses the declaration’s namespace. For example:

namespace Q {
    namespace V {
        void f();
    }

    void V::f() { }        // ok
    void V::g() { }        // error, g() is not yet a member of V

    namespace V {
        void g();
    }
}