二进制表达式('std :: ostream'(aka'basic_ostream< char>')和'const char *')的无效操作数 [英] invalid operands to binary expression ('std::ostream' (aka 'basic_ostream<char>') and 'const char *')

查看:208
本文介绍了二进制表达式('std :: ostream'(aka'basic_ostream< char>')和'const char *')的无效操作数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用Cheerp编译我的c ++代码(使用clang ++)时,我从终端获得以下输出:

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 << ")";
    ~~~ ^  ~~~

这是我对终端的命令:

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


推荐答案

已修复::我只是忘了到 #include< iostream>

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

这篇关于二进制表达式('std :: ostream'(aka'basic_ostream&lt; char&gt;')和'const char *')的无效操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆