+ 3
How to make a destructor
Destructor
7 Answers
+ 12
class DestructorExample
{
int* data;
public:
DestructorExample() // constructor
{
// init data here
}
~DestructorExample() // this is the destructor
{
// free data here
}
};
+ 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
+ 4
class Sample{
public:
Sample(){
// this is the constructor of sample class
}
~Sample(){
// this is the destuctor of sample class
}
};
+ 4
to make destructor you need to put this sign ~
before class token!
+ 3
what is a destructor? sure, for destructing data I suppose, but what would you use it for in real life. any examples please?
0
To make a destructor just put a telda sign(~) in followed by the class name.