Cpp namespaces
From wikinotes
namespaces are just what they sound like. A named container for variables, functions, etc.
Declare namespace
namespace cars{ int a = 0; int b = 0; void myfunc(){ return 0; } } namespace trucks{ int a = 1; int b = 1; void myfunc(){ return 1; } }
Accessing namespace
// access namespace cout << cars::a; // print a from namespace 'cars' cout << trucks::a; // print b from namespace 'trucks' // import namespace into local namespace using namespace trucks cout << a; // print a from namespace 'trucks' cout << cars::a; // print a from namespace 'cars'std namespace
the std namespace contains the majority of the builtin variables, function, class types. Pretty much all cpp functions will likely import it into the local namespace.