Quantcast
Channel: C++11 interface pure virtual destructor - Stack Overflow
Viewing all articles
Browse latest Browse all 4

C++11 interface pure virtual destructor

$
0
0

UPD. There is a mark that it is a duplicate of this question. But in that question OP asks HOW to use default to define pure virtual destructor. This question is about what the difference.

In C++ (latest standard if possible) what the real difference between defining pure virtual destructor with empty body implementation and just a empty body (or default)?

Variant 1:

class I1 {public:    virtual ~I1() {}};

Variant 2.1:

class I21 {public:    virtual ~I21() = 0;};I21::~I21() {}

Variant 2.2:

class I22 {public:    virtual ~I22() = 0;};I22::~I22() = default;

Update I found at least 1 difference between Variant 1 and Variants 2.1/2.2:

std::is_abstract::value is false for Variant 1, and true for Variants 2.1 and 2.2.

Demo

May be someone can found difference between 2.1 and 2.2?


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>