Thursday, 31 January 2013

Destructor


By on 00:36

Destructor:-Destructor is the member function of the class whose work is to destroyed the object that was created by constructor.

Important Properties/characteristics of Destructors:-


1)It always declare in public.


2)Destructor name is same as name of class.


3)Proceed with ~(tiled) sign.


4)It is the member function of class.


5)It has no parameter.


6)It is used to de-allocate the memory.


7)Destrcutor Overloading is not possible.


9)Destructor concept used in many languages like c ++(c plus plus),java,c#(c sharp) etc.


Example of Destructor(in c++):-Now I explain destructor example in c++ but you can also creat it with c sharp(#)(in place of cout puts Console.WriteLine and in place of cin puts Console.ReadLine) as same as like java(But some concept are different).



class stud

{
int stud-id;
public:
stud()
{
stud-id=1;
}
void show()
{
cout<<stud-id;
}
~stud()
{
cout<<"I AM DESTRUCTOR";
}};



If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...