Is it wrong to write:
class A { public: virtual ~A() = 0; };
for an abstract base class?
At least that compiles in MSVC… Will it crash at run time?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. You also need to implement the destructor:
should suffice.
If you derive anything from A and then try to delete or destroy it,
A‘s destructor will eventually be called. Since it is pure and doesn’t have an implementation, undefined behavior will ensue. On one popular platform, that will invoke the purecall handler and crash.Edit: fixing the declaration to be more conformant, compiled with http://www.comeaucomputing.com/tryitout/