Pure virtual destructor with default keyword
Is it possible to declare a destructor as pure virtual and use the default keyword? For example, I cannot make the code this way:
class MyClass
{
public:
// Is there a way to combine pure virtual and default?
virtual ~ MyClass() = 0,default;
};
You can, of course, later:
MyClass::~ MyClass() = default;
Also, if the destructor is not purely virtual, the default keyword works when it follows the declaration.
source to share
No, It is Immpossible.
By declaring a member function with a qualifier = default
, you provide the function definition.
From the working draft of the C ++ 14 standard (N3936):
ยง 10.4 Note. A function declaration cannot provide both a specifier and a definition
https://github.com/cplusplus/draft/raw/b7b8ed08ba4c111ad03e13e8524a1b746cb74ec6/papers/N3936.pdf
source to share
This question does not seem to be a starter since you can only have one destructor . Why do you need to add a specifier default
?
source to share