3 ms·
To resolve ambiguities due to the fact that in C, type names live in a separate namespace from variable names so that it's possible to have a variable with the
by Maxatar 3y ago
To resolve ambiguities due to the fact that in C, type names live in a separate namespace from variable names so that it's possible to have a variable with the same name as a type.
C++ inherits this distinction so that it is possible to write the following:
struct foo { int x; };
struct bar : foo { ::foo foo; };
bar b;
b.foo::x = 1;
b.foo.x = 2;
The b.foo::x and b.foo.x are two different x's, and the only way to disambiguate them is through the use of the . or the ::