The program below does not compile. Which statement correctly describes the problem?
#include <iostream>
struct Flag {
bool on;
int operator?:(int a, int b) const { return on ? a : b; }
};
int main() {
Flag f{true};
std::cout << (f ? 1 : 2) << '\n';
return 0;
}
Use a named function, or an explicit operator bool so f ? 1 : 2 uses the built-in conditional.