Answer: Destructors are used to destruct instances of classes.
Destructors cannot be defined in structures, they are only used with classes.
A class can only have one destructor.
Destructors cannot be inherited or overloaded.
Destructors cannot be called, they are invoked automatically.
A destructor does not take modifiers or have parameters.
Example:
class Car
{
~ Car() // destructor
{
// cleanup statements...
}
}
Asked In: Many Interviews |
Alert Moderator