The namespace keyword can be used in a namespace definition, a namespace alias definition, or a using directive. A namespace is a scope for declarations of classes, templates, functions, objects, and other namespaces. Outside a namespace, you can refer to a name that is declared in the namespace by qualifying the name with the scope operator (::), such as ns::name, or with a using directive or declaration. Multiple namespace declarations can name the same namespace, each one adding more declarations to the namespace. The standard namespace, std, is built this way, with many different headers all placing their declarations in the std namespace. A namespace can be anonymous, which prevents the enclosed declarations from being visible in other source files. A namespace alias defines an identifier as a synonym for an existing namespace. See using for information on the using directive. Examplenamespace math_version_2 { const long double pi = 3.1415926535897932385L; }; namespace math = math_version_2; using namespace math; See Alsoclass, declaration, identifier, using, Chapter 2 |