我可以撤消“使用命名空间”的效果在C ++? [英] Can I undo the effect of "using namespace" in C++?
问题描述
使用 using namespace
我使该命名空间的整个内容直接可见,而不使用命名空间限定符。这可能会导致问题,如果使用命名空间
发生在广泛使用的标题 - 我们可以无意地使两个命名空间具有相同的类名称可见,编译器将拒绝编译,除非类名称前面
With using namespace
I make the whole contents of that namespace directly visible without using the namespace qualifier. This can cause problems if using namespace
occurs in widely used headers - we can unintendedly make two namespaces with identical classes names visible and the compiler will refuse to compile unless the class name is prepended with the namespace qualifier.
我可以使用命名空间撤销,以便编译器忘记以前看到它吗? / p>
Can I undo using namespace
so that the compiler forgets that it saw it previously?
推荐答案
不,但你可以告诉同事,你不应该有使用
指令或声明。
No, but you can tell your coworkers that you should never have a using
directive or declaration in a header.
这篇关于我可以撤消“使用命名空间”的效果在C ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!