Explain the concept of destructor?

Author Topic: Explain the concept of destructor?  (Read 3588 times)

Offline beingchinmayTopic starter

  • Trade Count: (0)
  • Jr. Member
  • **
  • Thank You 1
  • Posts: 73
  • Karma: 0
  • Gender: Male
  • I am Chinmay
    • Modular Kitchen Designer
Explain the concept of destructor?
« on: 03-27-2017, 06:23:50 »
A destructor is a special method for a class and is invoked automatically when an object is finally destroyed. The name of the destructor is also same as that of the class but is followed by a prefix tilde (~).

A destructor is used to free the dynamic allocated memory and release the resources. You can, however, implement a custom method that allows you to control object destruction by calling the destructor.

The main features of a destructor are as follows:

 Destructors do not have any return type
 Similar to constructors, destructors are also always public
 Destructors cannot be overloaded


Related Topics

  Subject / Started by Replies Last post
3 Replies
Last post 08-08-2012, 22:16:01
by masterharvest
27 Replies
Last post 10-10-2016, 03:16:57
by Tabslogic
4 Replies
Last post 02-04-2015, 21:24:37
by dragon
11 Replies
Last post 06-30-2017, 12:08:30
by steffidsouza46
1 Replies
Last post 07-07-2021, 11:02:56
by Lishmalinyjames