用std::cout输出关系运算表达式时,关系表达式要加括号,否则编译会报错。例如:
#include <iostream>
int main(int argc, char **argv) {
std::cout << 1 < 2 << std::endl;
return 0;
}
在 linux 中编译后报错内容如下:
test.cpp: In function 'int main(int, char**)':
test.cpp:4:24: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
4 | std::cout << 1 < 2 << std::endl;
|
标签:cout,int,C++,char,报错,test,表达式
From: https://www.cnblogs.com/asagi/p/17447238.html