Aryan PrajapatKnowledge Contributor
What are destructors in C++?
What are destructors in C++?
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.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
Destructors are members of functions in a class that delete an object when an object of the class goes out of scope. Destructors have the same name as the class preceded by a tilde (~) sign. Also, destructors follow a down-to-top approach, unlike constructors which follow a top-to-down.
A destructor is a member function that is invoked automatically when the object goes out of scope or is explicitly destroyed by a call to delete or delete[] . A destructor has the same name as the class and is preceded by a tilde ( ~ ). For example, the destructor for class String is declared: ~String() .