Namespaces

Namespaces

Namespaces provide a method for preventing name conflicts in large projects.

Symbols declared inside a namespace block are placed in a named scope that prevents them from being mistaken for identically-named symbols in other scopes.

Multiple namespace blocks with the same name are allowed. All declarations within those blocks are declared in the named scope.

Syntax

namespace ns_name { declarations } (1)
inline namespace ns_name { declarations } (2) (since C++11)
namespace {