开发者

Why is the C++ scope resolution operator ::?

开发者 https://www.devze.com 2023-04-03 23:12 出处:网络
This is one of the few questions I didn\'t find an answer to in Design and Evolution of C++ by Stroustroup.Why is the C++ scope resolution operator ::, as opposed to just :?

This is one of the few questions I didn't find an answer to in Design and Evolution of C++ by Stroustroup. Why is the C++ scope resolution operator ::, as opposed to just :?

I'm guessing it's becaus开发者_运维百科e : is already used to indicate the start of an initialization list in a constructor. Does anyone else agree, disagree, or have a definitive answer on this?


It would create an ambiguity with goto labels, for one.

foo:bar;  // is foo a label or a namespace?
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号