What is the different between these two?
cpp-file:
namespace
{
int var;
}
or
int var;
if both
Two points:
extern int var;
can access your variable if it's not in an unnamed namespace.int var
global variable, you will have multiple definitions of this variable.As specified in the standard :
[...] all occurrences of unique in a translation unit are replaced by the same identifier and this identifier differs from all other identifiers in the entire program.