Exagon Exagon - 2 months ago 9
C++ Question

Why do we access enum values with ::

My question is simple and maybe stupid.
Whats the design decision behind accessing enum members via

::
in C++, when we access struct and class members via
.

Answer

:: is used when the left operand is the name of a type or namespace and . is used when the left operand is an object. For the same reason static members of structs or classes are also accessed using ::.

Comments