Answer the question
In order to leave comments, you need to log in
Is it always false == 0, true == 1 in C++?
Will this code always work correctly?
int A[2] = { 3, 5 }, y, z;
bool x = false;
y = A[x]; // y==3
z = A[!x]; // z==5
Answer the question
In order to leave comments, you need to log in
Everything about this is clear in the standard.
eelis.net/c++draft/conv.prom#6
In C++, there are a billion and 1 ways to shoot yourself in the foot or give yourself a headache for a couple of weeks with a small line, and on different compilers this number and cold-blooded tricks vary. For example classic
In, I dug up an ancient funny joke.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question