返回信息流rror C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class std::basic_istream<char,struct std::char_traits<char> >' (or there is no acceptable conversion)
这个上网查了下,说把头文件里的include<iostream.h>改成include<iostream>就好了,但是我的还是编译不过,有人说是VC6.0里友元函数重载运算符就会有问题,不知道是不是这样,有什么解决的办法么?求解答……
这是一条镜像帖。来源:北邮人论坛 / cpp / #41666同步于 2010/7/22
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
MFC里的重载问题……求助~~~~(>_<)~~~~
Carrie0593
2010/7/22镜像同步9 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
你写的这一句
把头文件里的include<iostream.h>改成include<iostream.h>就好了
有什么不一样?
【 在 Carrie0593 (噢卖糕的~\(≧▽≦)/~) 的大作中提到: 】
: rror C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class std::basic_istream<char,struct std::char_traits<char> >' (or there is no acceptable conversion)
: 这个上网查了下,说把头文件里的include<iostream.h>改成include<iostream.h>就好了,但是我的还是编译不过,有人说是VC6.0里友元函数重载运算符就会有问题,不知道是不是这样,有什么解决的办法么?求解答……
额……把.h删掉,写错了,囧
【 在 gootyking 的大作中提到: 】
: 你写的这一句
: 把头文件里的include<iostream.h>改成include<iostream.h>就好了
: 有什么不一样?
: ...................
class Players: public Staffs
{
public:
Players();
virtual ~Players();
int get_fee();
int get_kick();
int get_experience();
void set_transfer_fee(int fee);
void set_kick(int k);
void set_experience(int e);
friend ostream& operator<<(ostream& act,Players& a)
{
act<<" "<<a.name<<" "<<a.age<<" "<<a.ability<<" "
<<a.salary<<" "<<a.transfer_fee<<" "<<a.kick<<" "<<a.experience<<endl;
return act;
}
friend istream& operator>>(istream& act,Players& b)
{
act>>b.name>>b.age>>b.ability>>b.salary>>b.transfer_fee>>b.kick>>b.experience;
return act;
}
private:
int transfer_fee;
int kick;
int experience;
};
【 在 Wing 的大作中提到: 】
: 请给出具体代码......
: --
这个问题和我的类似吧http://forum.byr.edu.cn/article/CPP/25615
当时版主说的是什么意思?版主现在不在线……