C
CrazyJohn
Hi guys,
This is my first time posting question here, if I break any rules,
please kindly point out. And I'm really glad to be a part of this
community.
Here is my question,
Our lecturer told us that Unnamed Namespace is an alternative to
Static Internal Variables, but he also said that Namespace has an
"Open" nature. Then, what if we create an integer variable in an
unnamed namespace in one file and then create another integer variable
with the same name in the unnamed namespace in another file? Will this
cause a naming conflict?
-- file1.cpp --
namespace
{
int chenchen;
}
-- file2.cpp --
namespace
{
int chenchen;
}
If there is a naming conflict, then Unnamed Namespace is not able to
function exactly the same as Static Internal Variable does; If there
is no conflict, then Unnamed Namespace doesn't have an "Open"
nature......So, why the standard includes such a feature?.......
( Sorry, I am new to C++, actually I don't even know what exactly I
should ask.....)
This is my first time posting question here, if I break any rules,
please kindly point out. And I'm really glad to be a part of this
community.
Here is my question,
Our lecturer told us that Unnamed Namespace is an alternative to
Static Internal Variables, but he also said that Namespace has an
"Open" nature. Then, what if we create an integer variable in an
unnamed namespace in one file and then create another integer variable
with the same name in the unnamed namespace in another file? Will this
cause a naming conflict?
-- file1.cpp --
namespace
{
int chenchen;
}
-- file2.cpp --
namespace
{
int chenchen;
}
If there is a naming conflict, then Unnamed Namespace is not able to
function exactly the same as Static Internal Variable does; If there
is no conflict, then Unnamed Namespace doesn't have an "Open"
nature......So, why the standard includes such a feature?.......
( Sorry, I am new to C++, actually I don't even know what exactly I
should ask.....)