Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2348961
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:09:15

#include
#include
using namespace std;
class person
{protected:
  string name;
  int age;
  char sex;
  public:
   person(){name="   ";age=20;sex='m';}
   person(string n,int a,char se):name(n),age(a),sex(se){}
    void display();  
};
void person::display()
{cout<<"姓名:"< cout<<"年龄:"< cout<<"性别"<}
class student:public person
{protected:
        int num;
float score;
 public:
   student():person(){num=0;score=0;}
   student(string n,int a,char se,int nu,float sco):person(n,a,se),num(nu),score(sco){}
   friend istream &operator>>(istream&input,student &s);
   friend ostream &operator<<(ostream &output,student &s);  
};
istream &operator>>(istream &input,student &s)
{cout<<"输入学生学号,姓名,性别,年龄,分数"< input>>s.num>>s.name>>s.sex>>s.age>>s.score;
 return input;
}
ostream &operator<<(ostream &output,student &s)
{output<return output;
}
class teacher:public person
{public:
string title;
 public:
teacher():person(){title="you xiou";}
 teacher(string n,int a,char se,string t):person(n,a,se),title(t){}
 friend istream &operator>>(istream &input,teacher &t);
 friend ostream &operator<<(ostream &output,teacher &t);  
};
 istream &operator>>(istream &input,teacher &t)
{cout<<"输入老师姓名,年龄,性别,职称"< input>>t.name>>t.age>>t.sex>>t.title;
 return input;
}
 ostream &operator>>(ostream &output,teacher &t)
{output<return output;
}
int main()
{student s;
 teacher t;
 cin>>s;
 cin>>t;
 cout< cout< return 0;}


--------------------next---------------------

阅读(1463) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~