B类的对象永远不会被删除,所以我想要禁用析构函数来节省空间。 我想知道,为什么A ::〜A()在B()中使用,尽管没有例外。
struct A
{
A() noexcept {}
~A() = delete;
};
struct B : public A
{
B() noexcept {}
~B() = delete;
};
g ++ - 7 -std = gnu ++ 1z说:
main.cpp: In constructor ‘B::B()’:
main.cpp:12:16: error: use of deleted function ‘A::~A()’
B() noexcept {}
^
main.cpp:7:3: note: declared here
~A() = delete;
^