Mar 23, 2007

Destructor in C++

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();
}

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive