// @topic T53105 12/04/2012 -- namespace, unnamed (anonymous) namespace
// @brief namespace bristolcc, nested namespace bristolcc_implementation
// example of a namespace:
namespace bristolcc {
class Box {
double m_value;
public:
// constructors
Box( double value )
:
m_value( value )
{
}
// operations
double get_value();
};//class Box
};//namespace bristolcc
// namespaces can be re-opened:
namespace bristolcc {
double Box::get_value() {
return m_value;
}
namespace bristolcc_implementation {
int count_teachers = 100;
};//namespace divsionIII
};//namespace bristolcc
// unnamed namespace is accessible only within the file they are created in.
// unnamed namespace hides its declaration outside a translation unit.
// unnamed namespace allows naming functions the same in different CPP files.
namespace {
int strange = 0;
int count_teachers = 500;
};
int main()
{
using namespace bristolcc;
using namespace bristolcc::bristolcc_implementation;
Box bx = 123.45;
double dbl = bx.get_value();
dbl = dbl * strange * ::count_teachers;
return 0;
}