Well, well, as another comment said, this is because C ++ works.
In the old days, we modeled something like this with something like
class Colors {
public:
static int RED = 0;
static int GREEN = 1;
static int YELLOW = 2;
}
Then an enumeration was added, so you did not need to write Colors.RED. It is essentially syntactic sugar.
Update
- , . , : ++ , JavaSccript . , .
++, - , Algol 60, , . - . , , .
{}. , , .
#include <stdlib> // copies a bunch of code into the file
int foo = 0;
int fn(){
int bar = 2 ;
if(bar == 2){
foo = bar;
cout << bar << nl;
cout << foo << nl;
}
cout << foo << nl ;
cout << bar << nl ;
}
? foo foo, , if. bar if, ( " " ) , if
, ++.