A Destructor is also a method which gets called whenever the object of class is destroyed which is an opposite to a constructor which gets called an object is created.
Destructor method also as the same name of a class. But prefixed with tild (~)operator.
Example :
Class test
{
test()
{
// Constructor
}
~test()
{
//Destructor
}
}
A Destructor method cannot have any modifiers as well as cannot have any input parameter.
Destructor method also as the same name of a class. But prefixed with tild (~)operator.
Example :
Class test
{
test()
{
// Constructor
}
~test()
{
//Destructor
}
}
A Destructor method cannot have any modifiers as well as cannot have any input parameter.
No comments:
Post a Comment