I tried to add bool value together, say:
bool i = 0, j = 0, k = 0;
cout << sizeof(i + j + k) << endl;
The result is 4, which means, the result is converted to a 'int' value.
I want to ask: Is this a C/C++ standard operation? does the compiler always guarantee that the temporary value to be converted to a larger type if it overflows? Thanks!
Thanks for the answers, one follow up question:
say, if I do:
unsigned short i = 65535, j = 65535;
cout << sizeof(i + j) << endl;
The result is 4. Why it's been promoted to 'int'?