错误:没有运算符<<匹配这些操作数? [英] Error: No operator &lt;&lt; matches these operands?

查看:46
本文介绍了错误:没有运算符<<匹配这些操作数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在练习一些 C++(试图离开 Java),我偶然发现了这个恼人的错误:错误:没有操作员 <<匹配这些操作数.我在这个网站上搜索了明确的答案,但没有运气,我确实发现我不是唯一一个.

I was practicing some c++ (trying to leave Java), and I stumbled on this annoying error saying:Error: No operater << matches these operands. I've searched this website for a clear answer and no luck, I did find that I'm not the only one.

这个错误在我的 .cpp 文件中,还有其他错误,但我现在不在意它们.

This error is in my .cpp file, there are other errors, but I'm not paying any mind to them right now.

void NamedStorm::displayOutput(NamedStorm storm[]){
    for(int i = 0; i < sizeof(storm); i++){
        cout << storm[i] << "\n";
    }
}

<<"有问题我不确定发生了什么.

Something is up with the "<<" im not sure whats going on.

推荐答案

既然你正在尝试cout一个类对象,你需要重载<<

Since you are trying cout a class object you need to overload <<

std::ostream& operator<<(ostream& out, const NamedStorm& namedStorm)

这篇关于错误:没有运算符<<匹配这些操作数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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