This is my small program:
enum Type
{
b = 1,
c = 2
};
int main()
{
Type b = b;
std::cout << b << std::endl;
return 0;
}
Which outputs 0. Can I conclude that the above definition consists of this sequential steps?
- Declaration of
b
as variable of typeType
- Definition of that variable and initialization with
0
default value - Evaluation of it's new value, which includes the variable itself (with value 0)
- Assigning that new value to variable.
And, do variables get initialized with 0 always, even if they are explicitly initialized?
My second question is - if it uses the variable in it's initialization list in specified example, why then I don't get error about ambiguity? Is compiler trying to find b
in the variable list first, and only then checks for declared enumeration?