Do I need virtual destructor when I am using boost::ublas matrix ?
By the way, my class is a template class.
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.
Do you mean you have this?
There’s nothing here that dictates you have a virtual destructor.
You want a virtual destructor when you intend on having users publically derive from your class. So that question should be “Users will publically derive from my class, do I need a virtual destructor?”. Yes, you do.
The reason is that doing this leads to undefined behavior:
This does not:
Note that it has nothing to do with what members there are in the base class. You always need a virtual destructor if users will be deleting derived classes through a pointer to a base class.
I would recommend you get a book so you know what it does, because it sounds like you just throw things around and hope it works, which isn’t a very good approach.