C++ namespaces

Namespaces is a language feature that can be used to declare modules in C++.

They can be also used for:

  • declaring semi-private parts of library (see "detail" namespace in Boost)
  • declaring private functions in module - using anonymous namespaces like the following:
    // afile.cpp
    namespace {
        void foo(); // not accessible outside of afile.cpp 
        void boo(); // can call foo 
    }
    

Most important namespace is "std" which includes most of C++ Standard Library elements.

Resources

Share

follow