注册 登录
编程论坛 VC++/MFC

请教下大家这段程序的错误在哪里?

家力掠 发布于 2016-01-31 17:20, 3154 次点击
程序代码:
#include <iostream>
#include <string>
using namespace std;
class Teacher
{
public:
    Teacher(string n, int ag, char s, string a, string te, string ti)
        :{age = ag; sex = s; tel = te; title = ti; addr = a; name = n; }
    void display();
protected:
    int age;
    char sex;
    string tel;
    string title;
    string addr;
    string name;
};

class Cadre: public Teacher
{
public:
    Cadre(string n, int ag, char s, string a, string te, string p, string ti)
        :Teacher(string n, int age, string a, string te, string ti) {post = p;}
protected:
    string post;
};

class Teacher_Cadre :public Cadre
{
public:
    void show();
    Teacher_Cadre(string n, int ag, char s, string a, string te, int w, string p, string ti)
        :Cadre(string n, int ag, char s, string a, string te, string p, string ti){wages = w; }
protected:
    int wages;
};

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

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

int main(void)
{
    Teacher_Cadre tea("chenxingyin", 18'f', "YangqiaoRoad,fuzhou", "15386479123", 5600"teacher", "dr.");
    tea.show();

    return 0;
}
编译出来挺多错误的,又不知道怎么改,只能过来求助。
2 回复
#2
家力掠2016-01-31 17:21
不好意思发错板块了。求管理员帮助删除下。很抱歉

#3
天使梦魔2016-01-31 18:20
你哪复制过来的,符号都是错的,自己都不看下先?
你想从中知道什么?

程序代码:
#include <iostream>
#include <string>
using namespace std;
class Teacher
{
public:
    Teacher(string n, int ag, char s, string a, string te, string ti){age = ag; sex = s; tel = te; title = ti; addr = a; name = n; }
    void display();
protected:
    int age;
    char sex;
    string tel;
    string title;
    string addr;
    string name;
};

class Cadre:public Teacher
{
public:
    Cadre(string n,int ag,char s,string a,string te,string p,string ti):Teacher(n, ag, s, a, te, ti){post = p;};
protected:
    string post;
};

class Teacher_Cadre :public Cadre
{
public:
    void show();
    Teacher_Cadre(string n, int ag, char s, string a, string te, int w, string p, string ti):Cadre(n, ag, s, a, te, p, ti){wages = w; }
protected:
    int wages;
};

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

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

int main(void)
{
    Teacher_Cadre tea("chenxingyin", 18, 'f', "YangqiaoRoad,fuzhou", "15386479123", 5600,"teacher", "dr.");
    tea.show();
    return 0;
}
1