How does comma operator work during assignment?

后端 未结 5 765
时光说笑
时光说笑 2020-12-06 17:46
int a = 1;
int b = (1,2,3);
cout << a+b << endl; // this prints 4
  1. Is (1,2,3) some sort of structure in c++ (some pri
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 18:22

    it probably used to be b = foo(1,2,3) but the foo got deleted accidentally. C doesn't complain about this kind of crap "it's a feature".

提交回复
热议问题