Destructor:
- The destructor of the name implies is used to destroy that have been created by the constructor.
- Whose name is the same as the class name but it is preceded by a title (~).
Rules of destructor:
- The destructor should start with a tilde(~) and the same name of the class.
- Destructors do not have parameters and return types.
Uses of destructor:
- Releasing memory of the objects.
- Releasing memory of the pointer variables.
- Closing files and resources.
Syntax:
Example:
No comments:
Post a Comment