c++报错undefined reference to "析构函数",引号里的析构函数是基类的析构函数,声明为了纯虚函数?

这是c++ primer plus第六版中的程序清单14.10,P560页。
一模一样,就是这样报错,也没办法继续写下去了。
自学的,没办法了,不知道找谁问,贼难受!!!

//类声明
#ifndef WORKER_H_
#define WORKER_H_

#include <string>

using std::string;

class Worker{
    private:
        string fullname;
        long id;

    protected:
        virtual void Data() const;
        virtual void Get();

    public:
        Worker() : fullname("no one"), id(0L) {}
        Worker(const string & s, long n) : fullname(s), id(n) {}

        virtual ~Worker() = 0;
        virtual void Set() = 0;
        virtual void Show() const = 0;
};

class Waiter : virtual public Worker
{
    private:
        int panache;

    protected:
        virtual void Data() const;
        virtual void Get();

    public:
        Waiter() : Worker(), panache(0) {}
        Waiter(const string & s, long n, int p = 0) : Worker(s, n), panache(p) {}
        Waiter(const Worker & wk, int p = 0) : Worker(wk), panache(p) {}

        void Set();
        void Show() const;
};

#endif
//实现文件
#include <iostream>
#include "worker.h"

using namespace std;

//Worker 方法
void Worker::Data() const
{
    cout << "名字:" << fullname << endl;
    cout << "工号:" << id << endl;
}

void Worker::Get()
{
    getline(cin,fullname);
    cout << "请输入工号:";
    cin >> id;
    while (cin.get() != '\n')   continue;
}




//Waiter 方法
void Waiter::Data() const
{
    cout << "等级:" << panache << endl;
}

void Waiter::Get()
{
    cout << "请输入等级:";
    cin >> panache;
    while (cin.get() != '\n')   continue;
}

void Waiter::Set()
{
    cout << "请输入服务员的姓名:" << endl;
    Worker::Get();
    Get();
}

void Waiter::Show() const
{
    Worker::Data();
    Data();
}

1个回答

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