Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

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:

// defining_namespace_members.cpp
// C2039 expected
namespace Q {
    namespace V {
        void f();

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

    namespace V {
        void g();
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.