Default pure virtual destructor

前端 未结 1 553
攒了一身酷
攒了一身酷 2020-12-08 04:06

In C++11, we are able to declare a destructor to be auto generated:

struct X {
  virtual ~X() = default;
};

Also, we can declare a destruct

相关标签:
1条回答
  • 2020-12-08 04:36

    In order to define a pure virtual method, you need a separate definition from the declaration.

    Therefore:

    struct X {
        virtual ~X() = 0;
    };
    
    X::~X() = default;
    
    0 讨论(0)
提交回复
热议问题