骑猪小道士 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条)

报告相同问题?

悬赏问题

  • ¥15 UE5样条线生成的网格UV问题
  • ¥15 如何用最短的时间大致看懂springboot+vue的项目
  • ¥15 (有偿)懂数值分析和含时变参数微分方程的来
  • ¥15 layui父页的数据表格如何用弹窗页提交后的查询数据来更新数据表格内容?
  • ¥15 abaqus随机生成二维颗粒
  • ¥15 安装ansys许可证管理器时出现了这个问题,如何解决?
  • ¥100 高价求算法,利用智能手机传感器计算车辆的三轴g值
  • ¥15 Blazor server 数据库操作异常,如何解决?(语言-c#)
  • ¥15 uni-app开发APP运行到浏览器访问接口跨域
  • ¥100 mfc消息自创建控件