#include <iostream>
#include <string>
using namespace std;
class Person
{
public:
Person(char *nam,char s,int a)
{strcpy(name,nam);sex=s;age=a;}
protected:
char name[20];
char sex;
int age;
};
__________________
{
public:
Teacher(char *nam,char s,int a,char *t):Person(nam,s,a)
{strcpy(title,t); }
protected:
char title[10];
};
class Student:__________________
{
public:
Student(char *nam,char s,int a,float sco): Person(nam,s,a),score(sco){}
protected:
float score;
};
class Graduate:public Teacher,public Student
{
public:
Graduate(char *nam,char s,int a,char *t,float sco,float w):
Person(nam,s,a),Teacher(nam,s,a,t),Student(nam,s,a,sco),wage(w){}
__________________
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"score:"<<score<<endl;
cout<<"title:"<<title<<endl;
cout<<"wages:"<<wage<<endl;
}
private:
float wage;
};
int main( )
{
char name[20],title[10],sex;int age;float score,wage;
while(cin>>name>>sex>>age>>title>>score>>wage)
{
Graduate grad1(name,sex,age,title,score,wage);
grad1.show( );
}
return 0;
}
输入
输入有多组测试数据,每行为一组测试数据,且用空格隔开个数据。
输出
根据程序代码输出相应的信息。
样例输入
Wangli f 24 assistant 89.5 1234.5
样例输出
name:Wangli
age:24
sex:f
score:89.5
title:assistant
wages:1234.5
慕课朵颐3509194
汉江怪人
相关分类