码迷,mamicode.com
首页 > 其他好文 > 详细

12周 项目2 老师兼干部类

时间:2014-05-15 04:32:56      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   c   ext   

#include <iostream>
#include <string>
using namespace std;
class Teacher
{
    public:
    Teacher(string nam,int ag,char s,string ad,int num,string t)
    {
        name=nam;
        age=ag;
        sex=s;
        add=ad;
        number=num;
        title=t;
    }
    void display()
    {
        cout<<"name:   "<<name<<endl;
        cout<<"age:    "<<age<<endl;
        cout<<"sex:    "<<sex<<endl;
        cout<<"add:    "<<add<<endl;
        cout<<"number: "<<number<<endl;
        cout<<"title:  "<<title<<endl;
    }
    protected:
    string name;
    string add;
    char sex;
    int age;
    int number;
    string title;
};
class Cadre
{
    public:
    Cadre(string nam,int ag,char s,string ad,int num,string pos)
    {
        name=nam;
        age=ag;
        sex=s;
        add=ad;
        number=num;
        post=pos;
    }
    void display()
    {
        cout<<"name"<<name<<endl;
        cout<<"age"<<age<<endl;
        cout<<"sex"<<sex<<endl;
        cout<<"add"<<add<<endl;
        cout<<"number"<<number<<endl;
        cout<<"post"<<post<<endl;
    }
    protected:
    string name;
    string add;
    char sex;
    int age;
    int number;
    string post;
};
class Teacher_Cadre:public Teacher,public Cadre
{
    public:
    Teacher_Cadre(string nam,int ag,char s,string ad,int num,string t,string pos,float w):
    Teacher(nam,ag,s,ad,num,t),Cadre(nam,ag,s,ad,num,pos),wages(w){}
    void show()
    {
        Teacher::display();
        cout<<"post:   "<<Cadre::post<<endl;
        cout<<"wages;  "<<wages<<endl;
    }
    private:
    float wages;
};
int main()
{
    Teacher_Cadre tc("zhao_jia",20,‘f‘,"Yantai",88888888,"president","caiwubu",20000);
    tc.show();

    return 0;
}

bubuko.com,布布扣

感悟:看着书上的例题,慢慢的做出来了

12周 项目2 老师兼干部类,布布扣,bubuko.com

12周 项目2 老师兼干部类

标签:style   blog   class   code   c   ext   

原文地址:http://blog.csdn.net/zjx211314/article/details/25736859

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!