Destructor:
A destructor is a member function which destructs or deletes an object.
When is destructor called?
A destructor function is called automatically when the object leaves scope:
(1) the function ends
(2) the program ends
(3) a block containing local variables ends
(4) a delete operator is called
Guidelines of destructor:
1) Destructors have the same name from the class gone before by a tilde (~)
2) Destructors don’t take any argument and don’t return anything.
Constructor:
1) A constructor is an uncommon type of member function that introduces an object automatically when it is created.
2) The compiler identifies a given member function is a constructor by its name and the return type.
3) A constructor has the same name from that of the class and it doesn’t have any return type.
Regards,
Nitesh Bavishiya