gpt4 book ai didi

具有未解析外部的 C++ 虚拟析构函数

转载 作者:搜寻专家 更新时间:2023-10-31 00:52:36 24 4
gpt4 key购买 nike

<分区>

我有两个类..

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_;
};

我收到“1 个 Unresolved external ”错误。根据我以前的经验,这通常意味着虚拟、覆盖或类似的东西有问题。我弄乱了这段代码,但无法使错误消失。有什么建议吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com