| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 617 人关注过本帖
标题:[求助]自己的inserter和extractor 实在不明白错在何处
只看楼主 加入收藏
realoneyjw
Rank: 1
等 级:新手上路
帖 子:99
专家分:0
注 册:2005-5-13
收藏
 问题点数:0 回复次数:1 
[求助]自己的inserter和extractor 实在不明白错在何处

创建了自己的inserter和extractor,但是有两处错误,实在没有想明白,求教于各位大侠 还望指点一二,小弟不甚感激。代码及出错信息如下: #include<iostream> using namespace std;

class stu { public: int num; char name[30]; float score; stu(){} friend ostream &operator>>(ostream &stream,stu obj); friend istream &operator<<(istream &stream,stu &obj); };

ostream &operator>>(ostream &stream,stu obj) { cout<<"No.\t"<<"Name\t"<<"Score"<<endl; stream<<obj.num<<"\t"; stream<<obj.name<<"\t"; stream<<obj.score<<endl; return stream; }

istream &operator<<(istream &stream,stu &obj) { cout<<"Enter the number:"<<endl; stream>>obj.num; cout<<"Enter the name:"<<endl; stream>>obj.name; cout<<"Enter the score:"<<endl; stream>>obj.score; return stream; }

int main() { stu a; cin>>a; cout<<a; return 0; } error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class stu' (or there is no acceptable conversion) error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class stu' (or there is no acceptable conversion) Error executing cl.exe.

搜索更多相关主题的帖子: extractor inserter 
2005-10-08 21:28
zorro2zzz
Rank: 1
等 级:新手上路
威 望:1
帖 子:96
专家分:0
注 册:2005-9-11
收藏
得分:0 
你自己用断点查一下试试看……

编程是啥东西,让俺瞧瞧……
2005-10-09 22:48
快速回复:[求助]自己的inserter和extractor 实在不明白错在何处
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016657 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved