gpt4 book ai didi

C++,错误 : "no operator " == "matches these operands ", ostream/istream

转载 作者:太空宇宙 更新时间:2023-11-03 10:39:52 24 4
gpt4 key购买 nike

<分区>

我对编码有点陌生,需要为某种数据库编写程序。我在 youtube 上看到了一些人的教程,复制了他的代码,但出现错误,我不知道如何解决。

错误:没有运算符“==”匹配这些操作数;引用 if (outs == cout)

代码如下:

void Employee::output(ostream& outs)
{
if (outs == cout)
{
outs << "Name: " << name << endl;
outs << "ID number: " << id_number << endl;
outs << "Address: " << address << endl;
outs << "Salary: " << salary << endl;
outs << "Years worked at company: " << year_started << endl;
}
else {
outs << name << endl;
outs << id_number << endl;
outs << address << endl;
outs << salary << endl;
outs << year_started << endl;
}
}

这是我声明输出的方式:

void output(std::ostream& outs);

使用#include < > 添加了 iostream 和字符串

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com