Build a better website in less than an hour with GoDaddy
Ad Get started today for FREE! no tech skills required. Get found on Google and top sites like Facebook

Nested namespaces by classes

It is possible to nest a namespace inside another namespace.

Classes, structs and unions are also namespaces, despite they have other purpose.

Theoretically it should be possible to nest namespaces inside classes, structs and unions, what could be very useful.

template<typename Typename>
struct Struct{
 namespace shared{
  Typename variable;
 }

 Struct():
  shared::variable(0)
 {}

 void function(){
  {
   //shared variable is visible
   using namespace shared;
  }
  //use special variable
  int variable;
 }
};