What is Destructor ?
Destructor :-
Destructor is a member function having the character ~(Tiled Symbol) followed by the function name which is same as the class name and automatically executed when the object is no longer needed.
Example :- class student
{
private:
int roll;
public:
student ()
{
Cout << “object is created”;
}
~ student()
{
Cout << “object is killed”;
}
};
Output : object is created
object is killed
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment