C++ Programming Code Examples C++ > Beginners Lab Assignments Code Examples Nested Namespace in C++ programming language Nested Namespace in C++ programming language You can create nested namespaces. One namespace can be a part of another namespace. For example, we can create namespace X, which will contain namespace Y: namespace X { void foo() { cout << "foo from X is called" << endl; } namespace Y { void foo() { cout << "foo from Y is called" << endl; } } } If you want to call function foo() from namespace Y, you will have to specify the full path to foo() function: X::Y::foo(); Above line of code means that you are calling function foo from namespace Y, which is a part of namespace X.