C++ 运算符重载

[复制链接]
查看11 | 回复1 | 2009-7-23 17:12:21 | 显示全部楼层 |阅读模式
friend ostream & Student::operator>(istream& is,Student& stu) //输入流重载
{
is>>stu.name>>stu.age>>stu.score;
return is;
}//大致如上,直接调试下就对了·
回复

使用道具 举报

千问 | 2009-7-23 17:12:21 | 显示全部楼层
#include#include#includeusing namespace std;class Student{public: string name;int age;int score;Student(){}Student(string n,int a,int s){ name=n;
age=a; score=s;}};//注意这里:对操作符s;list::iterator i;string name;int age,score;for(int k=0;k>name>>age>>score;
s.push_front(Student(name,age,score));}for(i=s.begin();i!=s.end();i++) cout>(istream&,&);friend ostream& operator &);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行