标题:求助55555
取消只看楼主
csurice
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2005-3-2
 问题点数:0 回复次数:2 
求助55555

#include <iostream.h> class PhoneNumber { friend ostream &operator<<(ostream &, const PhoneNumber &); friend istream &operator>>(istream &,PhoneNumber &); private: char areaCode[4]; char exchange[4]; char line[5]; } ostream &operator<<(ostream &output,const PhoneNumber &num) { output<<"("<<num.areaCode<<")" <<num.exchange<<"-"<<num.line; return output; } istream &operator>>(istream &input,PhoneNumber &num) { input.ignore(); input.getline(num.areaCode,4); input.ignore(2); input.getline(num.exchange,4); input.ignore(); input.getline(num.line,5);

return input; } main(); { PhoneNumber phone; cout<<"Enter a phone number in the " <<"form(123)456-789:\n"; cin>>phone; cout<<"The phone number entered was:\n" <<phone<<endl; return 0; } 各位帮忙看一下这个程序有问题么,运算符重载搞不懂啊。 各位帮帮派啊,先谢啦

搜索更多相关主题的帖子: exchange private include return friend 
2005-04-03 16:01
csurice
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2005-3-2
得分:0 
不知道是不是我的编译器有问题,构造函数不能用该::符号在外面初始化啊,只能在定义构造函数时初始化哦。
其它运算符重载也不行啊。它显示重出错啊。
请高手帮帮忙啊
2005-04-03 22:43
csurice
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2005-3-2
得分:0 
谢谢各位啊
我现在知道错在哪
真的谢谢啦!
2005-04-04 22:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-14717-1-1.html




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

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