1 c++ iostream operator-overloading operators
我是一个新的编码,需要为某种数据库做一个程序.我看到一些关于youtube的教程,复制了他的代码,但是我得到了一个错误,我不知道如何解决它.
错误:没有运算符"=="匹配这些操作数; 参考if(out == 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;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我如何声明输出:
void output(std::ostream& outs);
Run Code Online (Sandbox Code Playgroud)
使用#include <>添加了iostream和字符串
| 归档时间: |
|
| 查看次数: |
370 次 |
| 最近记录: |