I want the code not to look like this:
int x = ...;
cout << "x=";
if(x)
cout << x;
else
cout << "???";
cout<<"!";
I really want something like:
cout << "x=" << (x ? x : "???") << "!";
But this does not compile, as xthey "???"are incompatible / different types.
Is there any way to do this neatly?
source
share