Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2545141
  • 博文数量: 308
  • 博客积分: 5547
  • 博客等级: 大校
  • 技术积分: 3782
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-24 09:47
个人简介

hello world.

文章分类

全部博文(308)

分类: C/C++

2010-11-25 16:40:16

#include <iostream>
using namespace std;

class Teacher
{
    public:
    Teacher(string,int,char,string,string,string);
    void display();
    
    private:
    string name;
    int age;
    char sex;
    string address;
    string phone;
    string title;
};
Teacher::Teacher(string name,int age,char sex,string address,string phone,string titile)
:name(name),age(age),sex(sex),address(address),phone(phone),title(title){}
void Teacher::display()
{
    cout << name << endl;
    cout << age << endl;
    cout << sex << endl;
    cout << address << endl;
    cout << phone << endl;
    cout << title << endl;
}

class Cadre
{
    public:
    Cadre(string name,int age,char sex,string address,string phone,string post);
    void display();
    
    private:
    string name;
    int age;
    char sex;
    string address;
    string phone;
    protected:
    string post;
};

Cadre::Cadre(string name,int age,char sex,string address,string phone,string post)
:name(name),age(age),sex(sex),address(address),phone(phone),post(post){}
void Cadre::display()
{
    cout << name << endl;
    cout << age << endl;
    cout << sex << endl;
    cout << address << endl;
    cout << phone << endl;
    cout << post << endl;
}

class Teacher_Cadre:public Teacher,public Cadre
{
   public:
   Teacher_Cadre(string name,int age,char sex,string address,string phone,string post,string title,int wages):
                        Teacher(name,age,sex,address,phone,title),
                        Cadre(name,age,sex,address,phone,post),wages(wages)
                        {}
   void show();
   private:
   int wages;
};

void Teacher_Cadre::show()
{
    Teacher::display();
    cout << "post:" << Cadre::post<< "wages:" << wages << endl;
}
int main()
{
    Teacher_Cadre tc("xiaopeng",26,'M',"zhengzhou","13526568417","ceo","teacher",2300);
    tc.show();
    system("pause");
    return 0;
}


    上面的代码,编译时没有错误。但在执行时,dos窗口自动关闭。一直查不清原因。愿高手刚我调试,并告诉我原因。谢谢了。
阅读(2765) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~