#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; } 各位帮忙看一下这个程序有问题么,运算符重载搞不懂啊。 各位帮帮派啊,先谢啦