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

后端 未结 4 1654
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条回答
  •  一个人的身影
    2020-12-28 15:18

    When I compile this code using GCC 4.3.4, I see a warning:

    prog.cpp: In function ‘int main()’:
    prog.cpp:6: warning: right-hand operand of comma has no effect
    

    ...though why it's a warning rather than an error, I don't know.

    EDIT: In fact, I don't know which comma it's referring to either, because this code:

    int const income = 0;
    std::cout << "I'm sorry your income is: " < income;
    

    ...generates the same warning (see here).

提交回复
热议问题