bean
bean

Reputation: 167

File-specific namespace

I'm wondering if there's something like a file-specific namespace in C++. Something like the following:

namespace thisFile
{
    // whatever code
};
using namespace thisFile;

where thisFile might get translated to some unique thing, such as:

namespace FAJIW0E0RTI43LNAFWENA
{
    // whatever code
};
using namespace FAJIW0E0RTI43LNAFWENA;

or perhaps there is an alternative convenient way to accomplish the same thing (i.e. without manually specifying a unique namespace).

Upvotes: 1

Views: 49

Answers (1)

Anton Savin
Anton Savin

Reputation: 41301

Use anonymous namespace:

namespace {
   ... 
}

Upvotes: 1

Related Questions