I know nesting of namespaces is allowed in C++/CLI. So my question is if we have something like this:
...
namespace one
{
// blah blah blah
// ...
namespace two
{
// another set of blah blah blah
// ...
}
}
and I need to use some functions and variables in namespace two, do I use:
one::two
or
one.two
Another question is that if I have a statement like
using namespace one;
do I have access to variables and functions in any nested namespaces like
namespace two
I’m asking because, in some programs I have seen (and written), there’s something like:
using namespace System;
using namespace System::Text;
using namespace System::IO;
Isn’t the System namespace supposed to cover the System::Text and System::IO namespaces?
You need to use
The
.operator is for accessing non-staticstruct/classmembers. Static members can then again be accessed through the scope resolution operator::.If you only would use
using System;, you could access theSystem::Textfunctions/variables byusingthe parent namespace does not imply importing all sub-namespaces.