What are the instances where you need to explicitly call a destructor?
Share
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.
When you use placement-new is a common reason (the only reason?):
This is mostly present in allocators (used by containers), in the
constructanddestroyfunctions, respectively.Otherwise, don’t. Stack-allocations will be done automatically, as it will when you
deletepointers. (Use smart pointers!)Well, I suppose that makes one more reason: When you want undefined behavior. Then feel free to call it as many times as you want… 🙂