【发布时间】:2014-02-24 01:46:16
【问题描述】:
这是我尝试构建时收到的错误消息:
'double' snd const char [3]' 类型的无效操作数到二进制'operator
显然我对此很陌生。任何帮助,将不胜感激。
代码如下:
#include <iostream>
using namespace std;
int main ()
{
double x = 3;
double y = 4;
cout << "(" << x = y++ << ", " << y << ")" << endl;
cout << "(" << x = ++y << ", " << y << ")" << endl;
cout << "(" << x = y-- << ", " << y << ")" << endl;
cout << "(" << x = --y << ", " << y << ")" << endl;
return 0;
}
【问题讨论】:
-
你需要括号:
cout << "(" << (x = y++) << ", " << y << ")" << endl;