Anonymous
Anonymous

Reputation: 3414

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

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 because : 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?

Upvotes: 3

Views: 348

Answers (1)

hammar
hammar

Reputation: 139840

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

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

Upvotes: 16

Related Questions