3

I have two classes..

template <class T>
class Node
{
protected:
    Node() = default;
    virtual ~Node() = 0;
    Node(const T& data) noexcept;
    Node(const Node<T> & copy) noexcept;
    Node(Node<T> && copy) noexcept;
    Node<T> & operator=(const Node<T> & rhs) noexcept;
    Node<T> & operator=(Node<T> && rhs) noexcept;
public:
    T & GetData() noexcept;
    T GetData() const noexcept;
    void SetData(const T & data) noexcept;
private:
    T data_;
};


template<class T>
class ListNode : public Node<T>
{
public:
    ListNode() = default;
    ListNode(const T& data, ListNode<T> * next = nullptr, ListNode<T> * previous = nullptr) noexcept;
    ListNode(const ListNode<T> & copy) noexcept;
    ListNode(ListNode<T> && copy) noexcept;
    ~ListNode() override = default;
    ListNode<T> & operator=(const ListNode<T> & rhs) noexcept;
    ListNode<T> & operator=(ListNode<T> && rhs) noexcept;
    ListNode<T> * GetNext() noexcept;
    ListNode<T> * GetPrevious() noexcept;
    void SetNext(ListNode<T> * const next) noexcept;
    void SetPrevious(ListNode<T> * const previous) noexcept;
private:
    ListNode<T> * next_;
    ListNode<T> * previous_;
};

I get an "1 unresolved externals" error. In my previous experience this would usually mean something is wrong with virtual, override, or something like that. I've messed around with this code but can't make the error go away. Any advice?

Jared
  • 2,029
  • 5
  • 20
  • 39

1 Answers1

4

Derived destructors always implicitly invoke the base destructor at the end of their execution. You have code that is trying to invoke an abstract function. You need to give ~Node() a definition with an empty function body:

virtual ~Node() {};
alter_igel
  • 6,899
  • 3
  • 21
  • 40