#include #include "namespaces.hpp" // to access a namespace the notation is `::' // it is possible to create nested namespaces (!) `::::elm' int math::dot(math::vec3i v, math::vec3i w) { return v.x * w.x + v.y * w.y + v.z * w.z; } // alternatively (but not recommended) we can enclose the code // in a namespace declaration namespace math { double dot(vec3d v, vec3d w) { return v.x * w.x + v.y * w.y + v.z * w.z; } } int main(int argc, char *argv[]) { math::vec3i a = { 1, 2, 3 }; math::vec3i b = { 1, 2, 3 }; std::cout << math::dot(a, b) << std::endl; // it is also possible to specify to implicitly // always use the namespace in a scope { using namespace math; vec3d c = { .5, .2, 11.2 }; vec3d d = { .2, .2, 12.3 }; std::cout << dot(c, d) << std::endl; } return 0; }