namespace Definition

A namespace-definition can be nested within another namespace-definition. Every namespace-definition must appear either at file scope or immediately within another namespace-definition.

For example:

namespace A {
    int j = 3;
    int f(int k);
}

namespace Outer {
    int n = 6;
    int func(int num);

    namespace Inner {
        float f = 9.993;
    }
}

void main()
{
    namespace local { ... }        // error: not at global scope
    .
    .
    .
}

Unlike other declarative regions, the definition of a namespace can be split over several parts of a single translation unit.

namespace A {
    // declare namespace A variables
    int i;
    int j;
}

namespace B {
    ...
}
    .
    .
    .
namespace A {
    // declare namespace A functions
    void func(void);
    int int_func(int i);
}

When a namespace is continued in this manner, after its initial definition, the continuation is called an extension-namespace-definition.