Explain the concept of destructor?

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

Offline beingchinmayTopic starter

  • Trade Count: (0)
  • Jr. Member
  • **
  • Thank You 1
  • Posts: 73
  • Karma: 0
  • Gender: Male
  • I am Chinmay
    • Fat Cutter
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
3651 Views
Last post 08-08-2012, 22:16:01
by masterharvest
27 Replies
12172 Views
Last post 10-10-2016, 03:16:57
by Tabslogic
4 Replies
2245 Views
Last post 02-04-2015, 21:24:37
by dragon
11 Replies
3620 Views
Last post 06-30-2017, 12:08:30
by steffidsouza46
0 Replies
1040 Views
Last post 11-04-2016, 03:26:04
by beingchinmay