当尝试使用Cheerp(使用clang ++)编译我的c ++代码时,我从终端获得此输出:
example.cpp:102:9: error: invalid operands to binary expression ('std::ostream'
(aka 'basic_ostream<char>') and 'const char *')
out << "(" << loc.x << ", " << loc.y << ")";
~~~ ^ ~~~
这是我对终端的命令:
/opt/cheerp/bin/clang++ -target cheerp example.cpp -o example.js
以下是它遇到问题的代码:
static std::ostream& operator <<(std::ostream & out, const CornerLoc &loc)
{
out << "(" << loc.x << ", " << loc.y << ")";
if (loc.type == kCorner)
out<<"-corner";
if (loc.type == kCornerNorthWest)
out<<"-cornerNW";
if (loc.type == kCornerNorthEast)
out<<"-cornerNE";
if (loc.type == kCornerSouthWest)
out<<"-cornerSW";
if (loc.type == kCornerSouthEast)
out<<"-cornerSE";
return out;
}
答案 0 :(得分:15)
FIXED ::我忘了#include <iostream>