Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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;
}
like image 841
Jonathan Allen Grant Avatar asked Jan 30 '16 22:01

Jonathan Allen Grant


1 Answers

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

like image 53
Jonathan Allen Grant Avatar answered Nov 12 '22 17:11

Jonathan Allen Grant