第十二周作业2

  
#include<iostream>  
 
#include<string>  
 
using namespace std;  
  
class Teacher  
{  
public:  
    Teacher(string nam, int a, char s, string tit, string ad, string t) : name(nam), age(a), sex(s), title(tit), addr(ad), tel(t){}//构造函数定义  
    void display();  
protected:  
    string name;  
    int age;  
    char sex;  
    string title;  
    string addr;  
    string tel;  
};  
  
void Teacher :: display()  
{  
    cout << "name:" << name << endl;  
    cout << "age:" << age << endl;  
    cout << "sex:" << sex << endl;  
    cout << "title:" << title << endl;  
    cout << "addr:" << addr << endl;  
    cout << "tel:" << tel << endl;  
}  
class Cadre  
{  
public:  
    Cadre(string nam, int a, char s, string p, string ad, string t) : name(nam), age(a), sex(s), post(p), addr(ad), tel(t){}//构造函数定义  
    void display();  
protected:  
    string name;  
    int age;  
    char sex;  
    string post;  
    string addr;  
    string tel;  
};  
  
void Cadre :: display()  
{  
    cout << "name:" << name << endl;  
    cout << "age:" << age << endl;  
    cout << "sex:" << sex << endl;  
    cout << "post:" << post << endl;  
    cout << "addr:" << addr << endl;  
    cout << "tel:" << tel << endl;  
}  
  
class Teacher_Cadre : public Teacher, public Cadre  
{  
public:  
    Teacher_Cadre(string nam, int a, char s, string tit, string p, string ad, string t, float w) : Teacher(nam, a, s, tit, ad, t), Cadre(nam, a, s, p, ad, t), wages(w){}  
    void show();  

private:  
    float wages;  
};  
  
void Teacher_Cadre :: show()  
{  
    Teacher :: display();  
    cout << "post:" << Cadre :: post << endl;  
    cout << "wages:" << wages << endl;  
}  
  
int main()  
{  
    Teacher_Cadre Teacher_Cadre1("wang-li", 25, 'f', "prof", "president", "135Beijing Road,Shanghai", "(021)61234567", 1534.5);  
    Teacher_Cadre1.show();  
    system("pause");  
    return 0;  
}
第十二周作业2_第1张图片

你可能感兴趣的:(String,System,Class,float,作业)