Typo with “cout < myint”. Why does it work?

后端 未结 4 1645
Happy的楠姐
Happy的楠姐 2020-12-28 14:41

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: \" < inco         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-28 15:39

    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.

提交回复
热议问题