一个C++的编程题 未定义的引用
#include <iostream>
#include <string.h>

using namespace std;
    class birthday
    {
        public:
        int year,month,day;
        birthday(int y=0,int m=0,int d=0)
        {
            year=y;
            month=m;
            day=d;
        }
        birthday(birthday&b)
        {
            year=b.year;
            month=b.month;
            day=b.day;
        }
        inline void showbirthday()//生日信息的展示
        {
        cout<<year<<"年"<<month<<"月"<<day<<"日"<<endl;
        }
        ~birthday(){};
    };
class People
{
public:
    char name[11];
    char number[7];
    char sex[3];
    char id[16];
    void showIF();//显示员工的信息
     People(People&p):Birthday(p.Birthday)
     {
            strcpy(name,p.name);
            strcpy(number,p.number);
            Birthday=p.Birthday;
            strcpy(sex,p.sex);
            strcpy(id,p.id);
     }
     People();
     People(char nm1[11],char id1[16],char sex1[3],char num1[7])
     {
        strcpy(name,nm1);
        strcpy(id,id1);
        strcpy(sex,sex1);
        strcpy(number,num1);
     };
    ~People(){};
     birthday Birthday;

};
inline void People::showIF()//展示信息,可能会多次使用设置为内联函数
{
    cout<<"name    number    sex(m/w)        id         birthday"<<endl;
    cout<<"                  "<<name<<"  "<<number<<"        "<<sex<<"       "<<id<<"  ";
    Birthday.showbirthday();
}
class student:virtual public People
{
public:
    char classNum[7];
    student(char nm2[11],char id2[16],char sex2[3],char num2[7],char CN[7]):People(nm2,id2,sex2,num2)
    {
        strcpy(classNum,CN);
    };
    void showStuIF()
    {
        cout<<"name    number    sex(m/w)        id         classNum      birthday"<<endl;
        cout<<"                  "<<name<<"  "<<number<<"        "<<sex<<"       "<<id<<"  "<<classNum<< "   ";
        Birthday.showbirthday();
    }
};
class teacher:virtual public People
{
public:
    char principalship[11];
    char department[21];
    teacher(char nm3[11],char id3[16],char sex3[3],char num3[7],char pr[11],char dp[21]):People(nm3,id3,sex3,num3)
    {
        strcpy(principalship,pr);
        strcpy(department,dp);
    };
    teacher();
    void showTEAIF()
    {
        cout<<"name    number    sex(m/w)        id               principalship   department    birthday"<<endl;
        cout<<"                  "<<name<<"  "<<number<<"        "<<sex<<"       "<<id<<"  "<<"       "<<principalship<<"       "<<department<<"     ";
        Birthday.showbirthday();
    }
    void showTeNM()
    {
        cout<<name;
    }
};
class graduate:public student
{
public:
    char subject[21];
    teacher Teacher;
    graduate(char nm4[11],char id4[16],char sex4[3],char num4[7],char CN1[7],char SJ[21]):student(nm4,id4,sex4,num4,CN1)
    {
        strcpy(subject,SJ);
    }
    void showGRIF()
    {
        cout<<"name    number    sex(m/w)        id         classNum      subject   teacher   birthday"<<endl;
        cout<<"                  "<<name<<"  "<<number<<"        "<<sex<<"       "<<id<<"  "<<classNum<< "   "<<subject<<"   "<<"   ";
        Teacher.showTeNM();
        Birthday.showbirthday();
    }
};
class TA:public graduate,public teacher
{
};
int main()
{
    student stu("2018044035","199905160015170","男","199905","03");
    teacher tea("1999033011","198007300080320","女","198007","学科主任","教务部");
    graduate GR("2015044025","199603250015170","男","199603","01","软件工程");
    stu.showStuIF();
    tea.showTEAIF();
    GR.showGRIF();
    return 0;
}

graduate(char nm4[11],char id4[16],char sex4[3],char num4[7],char CN1[7],char SJ[21]):student(nm4,id4,sex4,num4,CN1)这一行出现了报错

E:\myprojiect\examsix\main.cpp|103|undefined reference to People::People()'|
E:\myprojiect\examsix\main.cpp|103|undefined reference to
teacher::teacher()'|

求助大佬们怎么jie'jue

c++

2个回答

People();
->
People() {}

~People();
->
~People() {}

1.图片说明

2.People(); -> People(){}

3.teacher(); -> teacher(){}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问