I have this code and I searched for hours why it fails to print my income
int const income = 0;
std::cout << "I'm sorry, your income is: " < income;
Until I found I missed to write <<
but wrote <
. Why doesn't the compiler detect this and error out? I'm not sure why comparing cout
makes sense?
integral constant 0 is also a null pointer constant - it can be compared to the result of ostream
's operator void *
. Note that it'll fail if the constant has any value but 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With