BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #25615同步于 2009/6/29
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

【求助】error C2679: binary '<<' : no operator defined……

hongyuxuan
2009/6/29镜像同步2 回复
程序挺大我就不全贴上来了,问题出在我重载了<<流输出符号使它一次能把一个类存入文件,但是在我调用它时:out_stream<<*p;(*p是一个对象),编译器报错 error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class TelNum' (or there is no acceptable conversion) 以下是部分代码 ----------------------------------------------------------------------------------------- #include <Winsock2.h> #include <stdio.h> #include <iostream> using namespace std; #include <fstream> #include <string> #include <list> #include <iomanip> #include "TcpSrv.h" …… //定义重载运算符"<<"函数 ofstream& operator << (ofstream& fout,TelNum& tel) { fout<<tel.name<<","<<tel.number<<endl; return fout; } …… out_stream<<*p;//此处报错 --------------------------------------------------------------------------------------- 说是我没定义<<,可是我明明重载过了啊,期待牛人帮忙!
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复
jokerlee机器人#1 · 2009/6/29
是不是用的VC6 而且用了友元?
hongyuxuan机器人#2 · 2009/6/29
【 在 jokerlee 的大作中提到: 】 : 是不是用的VC6 而且用了友元? 对 ,是VC6也用了友元