| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 520 人关注过本帖
标题:帮忙查看一下 c++ 多重继承 问题
取消只看楼主 加入收藏
sun004715
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2010-10-30
结帖率:100%
收藏
已结贴  问题点数:0 回复次数:0 
帮忙查看一下 c++ 多重继承 问题
/*
 * practise-9.cpp
 *
 *  Created on: 2010-11-11
 *      Author: sun
 */

#include <iostream>
using namespace std;

class Teacher
{
public:
    Teacher(char nam[], int ag, char se, string add, long num, string tit)
    {
        strcpy(name, nam);
        age = ag;
        sex = se;
        addr = add;
        number = num;
        title = tit;
    }
    void display(void);
private:
    char name[10];
    int age;
    char sex;
    string addr;
    long number;
    string title;
};

class Cadre
{
public:
    Cadre(char nam[], int ag, char se, string add,  long num, string pos)
        {
            strcpy(name, nam);
            age = ag;
            sex = se;
            addr = add;
            number = num;
            post = pos;
        }
private:
    char name[10];
    int age;
    char sex;
    string addr;
    long number;
    string  post;
};

class Teacher_Cadre : public Teacher, public Cadre
{
public:
    Teacher_Cadre(string nam, int ag, char se, string add, long num,string tit, string pos, int wage):
        Teacher(string nam, int ag, char se, string add, long num, string tit),
        Cadre(string nam, int ag, char se, string add, long num, string pos),wages(wage){}  //定义构造函数时报错,错误提示在下面
    void show(void);
private:
        char name[10];
        int age;
        char sex;
        string addr;
        long number;
        int wages;
        string  post;
        string title;
};

void Teacher :: display(void)
{
    cout << "name=" << name << " age=" << age << "sex=" << sex <<"title=" << title <<
            "address=" << addr << "number=" << number << endl;
}

void Teacher_Cadre :: show(void)
{
    display();
    cout << "post=" << post << "wages=" << wages << endl;
}

int main(void)
{
    Teacher_Cadre li("Li", 35, 'm',"chengdu", 8888888, "yuwen", "zhuren", 5000);
    li.show();
    return 0;
}



以下是Eclipse下编译的错误
..\practise-9.cpp:58: error: expected primary-expression before "char"
..\practise-9.cpp:58: error: expected primary-expression before "int"
..\practise-9.cpp:58: error: expected primary-expression before "char"
..\practise-9.cpp:58: error: expected primary-expression before "add"
..\practise-9.cpp:58: error: expected primary-expression before "long"
..\practise-9.cpp:58: error: expected primary-expression before "tit"
..\practise-9.cpp:59: error: expected primary-expression before "char"
..\practise-9.cpp:59: error: expected primary-expression before "int"
..\practise-9.cpp:59: error: expected primary-expression before "char"
..\practise-9.cpp:59: error: expected primary-expression before "add"
..\practise-9.cpp:59: error: expected primary-expression before "long"
..\practise-9.cpp:59: error: expected primary-expression before "pos"

劳烦 帮忙指出错误原因,该怎么改呢
搜索更多相关主题的帖子: 继承 
2010-11-11 11:05
快速回复:帮忙查看一下 c++ 多重继承 问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025051 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved