Namespaces:
A namespace is designed for providing a way to keep one set of
names separate from another.
The class names declared in one namespace does not conflict with
the same class names declared in another.
Defining a Namespace
A namespaces definition begins with the keyword namespace followed by the namespace name as followed:
namespace namespace_name {
// your code
}
To call the namespace-enabled version of either function or variable, prepend the namespace keyword as followed:
namespace_name.item_name;
Nested Namespaces:
You can define one namespace inside another namespace as followed:
namespace namespace_name1 {
// your code
namespace namespace_name2 {
// your code
}
}
Note: You can access members of nested namespace by using the dot (.) operator.
Top comments (0)