Ternary operator ?: vs if…else

It is not faster. There is one difference when you can initialize a constant variable depending on some expression:

const int x = (a<b) ? b : a;

You can’t do the same with if-else.

Leave a Comment