Confusion About C++ Global Namespace -
from understanding, appending ::
front of namespace refers global namespace, regardless of using statements or parent namespaces. if case, , haven't mis-understood anything, why such code compile (at least in visual studio):
namespace foo { namespace bar { class x; } } using namespace foo; int main(void) { ::bar::x x; }
using namespace foo;
brings contents of namespace foo
context of current namespace.
since namespace bar
among contents of namespace foo
, current namespace on line using
statement global namespace, namespace bar
brought context of global namespace.
Comments
Post a Comment