骑猪小道士 2019-06-06 00:18 采纳率: 50%
浏览 625
已采纳

一个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

  • 写回答

2条回答 默认 最新

  • threenewbee 2019-06-06 10:36
    关注

    People();
    ->
    People() {}

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R