destructor : is a member function of a class. it has same name as a class.
followed by a tilde sign ~ it does not have return type (neither int nor void) . it automatically
get executed when object is destroyed.
#include<iostream.h>
#include<conio.h>
class student // student is a class
{
public :
~student() // destructor
{
cout <<"Thanx for using this program" <<endl;
}
};
main()
{
clrscr();
student s1; // s1 is an object
getch();
}
Mar 23, 2007
Destructor in C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment