In C++, is the ?: operator faster than if()...else statements? Are there any differences between them in compiled code?
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.
if-else
1.4m articles
1.4m replys
5 comments
57.0k users