Why is it forbidden to open multiple namespaces at a stretch?

让人想犯罪 __ 提交于 2019-12-03 10:17:16

I'm not sure "forbidden" is the right word - maybe it was just an oversight. It's a fairly small nice-to-have which isn't really a big deal.

You could also take the point of view that the namespace foo isn't created yet when you write foo::bar, so allowing that syntax makes it look like foo was already created when it was not.

You could also go further and request the ability to write class Foo::MyClass {... to define MyClass in namespace Foo, and the same for functions, variables, etc. But is this feature really necessary and solving any particular pressing problem?

Why make compilers implement it when you could just do

namespace foo { namespace bar {

}}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!