When I read the chapter of the namespace of the book C++ Primer(3e).
It explain the using directive as follow:
"A using directive makes the namespace member names visible as if they
were declared outside the namespace at the location where the namespace
definition is located."
I have some doubt about the using directives for the nested namespace,
so I wrote a program to test it,
#include <iostream>
namespace test
{
namespace nested
{
void foo() {}
}
}
using namespace test::nested;
int main()
{
foo()
return 0;
}
I think this program will wrong when compile it. But it is correct.
Why??
I think the statement "using namespace test::nested;" make the
namespace like this
namespace test
{
void foo() {};
}
and the function foo can't be seen in the main() function.
But this program can compile without error. How does it happen??
Thanks for anwsering it, and forgiving my poor English.