在virtual function中比較特殊的就是virtual destructor,因為它不會被override,而是被壓進一個stack,先執行derived class的destructor。
因此若要宣告一個pure virtual destructor,它依然不能缺少定義:
/// @file interface.hpp
// ...
class Interface {
    // ...
    virtual ~Interface() = 0;
    // ...
};
// ...
/// @file interface.cpp
// ...
Interface::~Interface() {}
// ...
Reference
沒有留言:
張貼留言