Destructor A destructor as the nameimplies is used to destory the objects that have been created by a constructor like a constructor the destructor is member function whose name is the same as the class nabe but is proceded by tilde.As you know that variables which i go out of the scope of the compiler gets removed from the memory by the compiler so that the memory by the compiler so that the memory which was under use can be reused to perform some other instructions.Similarily in c++ we can utilize an member function called as Destructor witch allows to delete the those objects which goes out of the scope of the compiler.
A destructor never takes any arguments nor does it return any value it eill nbe invoked implicitly by the compiler upon exit form the program to clean up the storage that is no longer accesible.
syn for declaring a destructor
-class name()
{
statement
}
No comments:
Post a Comment