anonymous namespace

Viewed 10898

What is the different between these two?

cpp-file:

namespace
{
    int var;
}

or

int var;

if both are put in the cpp file? Is not correct that we put a variable in anonymous namespace so it can be private for just that file? But if we put a global variable in a cpp file is not that variable also privat because you never do an include to .cpp file?

5 Answers
Related