&怎么用的
程序代码:
#include"iostream.h" class cstudent { public: friend ostream& operator<<(ostream& os,cstudent stu); friend istream& operator>>(istream& is,cstudent& stu); private: char strname[10]; char strid[10]; int fscore[3]; }; ostream& operator<<(ostream &os,cstudent stu) { os<<endl<<"请输入学生信息:"<<endl<<"姓名"<<stu.strname<<endl<<"学号"<<stu.strid<<endl; os<<"三门成绩为:"<<stu.fscore[0]<<"\t"<<stu.fscore[1]<<"\t"<<stu.fscore[2]<<endl; return os; } istream& operator>>(istream& is,cstudent& stu) { cout<<"请输入学生信息:"<<endl<<"姓名"; is>>stu.strname; cout<<"学号:"; is>>stu.strid; cout<<"三门成绩"; is>>stu.fscore[0]>>stu.fscore[1]>>stu.fscore[2]; return is; } void main() { cstudent one ; cin>>one; cout<<one; } friend ostream& operator<<(ostream& os,cstudent stu); friend istream& operator>>(istream& is,cstudent& stu);这两个定义为什么不一样 ,多了个& ,还有这里面的所有&的位置到底是怎么放的 怎么书上有放在左 放在右 ,但是我换个位置 编译没错误 运行就不行啊