+ 3

How to make a destructor

Destructor

11th Jun 2017, 8:33 AM
rahul sharma
rahul sharma - avatar
7 Answers
11th Jun 2017, 10:35 AM
Drinker
Drinker - avatar
+ 12
class DestructorExample { int* data; public: DestructorExample() // constructor { // init data here } ~DestructorExample() // this is the destructor { // free data here } };
11th Jun 2017, 9:10 AM
Karl T.
Karl T. - avatar
+ 7
@Ben Harp Restaurants. At the end of your meal a "buser" sweeps through and resets everything in your dining area for the next patrons, at which time the table is ready to be 'initialized'/'allocated', 'populated' and 'destroyed' again. Or humor...Ghostbusters (time index near key phrase) https://youtu.be/4JVkonHpxKk?t=16
12th Jun 2017, 4:28 PM
Kirk Schafer
Kirk Schafer - avatar
+ 4
class Sample{ public: Sample(){ // this is the constructor of sample class } ~Sample(){ // this is the destuctor of sample class } };
11th Jun 2017, 9:55 AM
NSA94
NSA94 - avatar
+ 4
to make destructor you need to put this sign ~ before class token!
12th Jun 2017, 5:28 PM
AL.The.Flame!
AL.The.Flame! - avatar
+ 3
what is a destructor? sure, for destructing data I suppose, but what would you use it for in real life. any examples please?
12th Jun 2017, 2:11 PM
Ben Harp
Ben Harp - avatar
0
To make a destructor just put a telda sign(~) in followed by the class name.
13th Jun 2017, 5:41 AM
Sanket Pawar
Sanket Pawar - avatar