Recently, we have just started reading the C + + textbook. found that they did not learn seriously, a lot of things pointed to the present only to understand. (Orz, ashamed)
I no longer want to see "using namespace xxx;" In any header file. The
Baidu I found this sentence, a careful look at the reason is because: http://www.ituring.com.cn/article/23606
If you use the using declaration in a header file, you will make this kind of problem even worse, because the naming conflict problem will sooner or later be in a module called very far away from the unknown,
You may need to check the three-layer call to find out why a header file contains another header file that directly uses the using declaration to cause the namespace to be contaminated immediately.
Any file that uses a namespace can cause this type of problem if it uses the contents of the Std namespace.
But a magical #pragma was found in vs once
is a more commonly used C + + pragma, as long as the header file at the very beginning of adding this pragma, you can ensure that the header file is only compiled once. #pragma once is compiler-related, some compiler support, some compilers do not support, please check the compiler API documentation for details, but now most compilers have this pragma. Is it possible to use the using namespace xxx with this sentence ~?!
C + + header file with using namespace Std