<分区>
我正在尝试声明纯虚拟析构函数, 在 VS2019 中我是这样写的:
virtual ~A() = 0 {};
这很好,但在 Clion 中不要接受 我收到以下消息:
pure-specifier on function-definition virtual ~A() = 0{ };
它迫使我为该函数编写一个不同的实现(不是很麻烦,但我想知道为什么会这样)
<分区>
我正在尝试声明纯虚拟析构函数, 在 VS2019 中我是这样写的:
virtual ~A() = 0 {};
这很好,但在 Clion 中不要接受 我收到以下消息:
pure-specifier on function-definition virtual ~A() = 0{ };
它迫使我为该函数编写一个不同的实现(不是很麻烦,但我想知道为什么会这样)
最佳答案
来自 C++ 20(11.6.3 抽象类)
- ...[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]
关于c++ - c++ Clion 和 VS2019 中的纯虚拟析构函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58097214/