22.13. The scope resolution operator and global functions

In C++, the ‘:: ’ is called the ‘scope resolution operator.’ If you put a class name like MyClass in front of the operator, this indicates that you want to use the version of the class method implemented by the MyClass code. If, for instance, you have a ChildClass and a ParentClass, then ParentClass::Method() and ChildClass::Method() could very well mean different things.

Some functions are ‘global’ functions that aren’t a member of any class at all. We try to make a practice of always putting two colons with no class name in front of a global function to remind ourselves that this is a function that doesn’t belong to any class. Ordinarily, putting the ‘:: ’ in front of a global function ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.