invalid operands to binary expression ('std::ostream' (aka 'basic_ostream<char>') and 'const char *') [closed]

◇◆丶佛笑我妖孽 提交于 2020-02-26 11:59:48

问题


When trying to compile my c++ code with Cheerp (using clang++), I get this output from my terminal:

example.cpp:102:9: error: invalid operands to binary expression ('std::ostream'
      (aka 'basic_ostream<char>') and 'const char *')
    out << "(" << loc.x << ", " << loc.y << ")";
    ~~~ ^  ~~~

Here is my command to the terminal:

/opt/cheerp/bin/clang++ -target cheerp example.cpp -o example.js

And Here is the code it has trouble with:

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;
}

回答1:


FIXED:: I just forgot to #include <iostream>



来源:https://stackoverflow.com/questions/35107801/invalid-operands-to-binary-expression-stdostream-aka-basic-ostreamchar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!