< Prev
Next >



Destructors in C++





In C++, a constructor is a special member function of class which is used to create and initialize its objects. Contrary to the working of a constructor, a destructor is also a special member function of a class, used to destroy the object of a class and to clean up its storage space, because this object is no longer accessible which were created by the constructor.

Some important features of a constructor are -




When a destructor is called?


A destructor is automatically called by the compiler when a program ends its execution or as soon as the closing brace } of a block or a function is encountered, and in this case the compiler calls the destructor which destroys all the objects created within that particular block/function.
Please subscribe our social media channels for notifications, we post a new article everyday.

Decodejava Google+ Page Decodejava Facebook Page  DecodeJava Twitter Page

Coming Next
-
Python

Ad2