I recently wrongly declared an int as a bool and got no type error from the g++ compiler. Then I tried it again for testing and it compiles fine. Can someone explain why this is acceptable behaviour? Shouldn't the compiler give me a warning at least when i try to ++
a boolean or when i assign a bool
as integer
.
int main(int argc, char** argv)
{
bool x = 0;
x++;
x++;
cout << x << "\n";
return 0;
}