c++ Clion 和 VS2019 中的纯虚拟析构函数

pure virtual destructors in c++ Clion and VS2019

我正在尝试声明纯虚拟析构函数, 在 VS2019 中我是这样写的:

    virtual ~A() = 0 {};

这很好,但在 Clion 中不要接受 我收到以下消息:

pure-specifier on function-definition virtual ~A() = 0{ };

这迫使我为该函数编写不同的实现(不是很麻烦,但我想知道为什么会这样)

来自 C++ 20(11.6.3 摘要 类)

  1. ...[Note: A function declaration cannot provide both a pure-specifier and a definition — end note] [Example:
struct C {
  virtual void f() = 0 { }; // ill-formed
};

— end example]