What is the use of destructor?Can any explain me deep using program?

Showing Answers 1 - 5 of 5 Answers

sankar

  • Jun 27th, 2006
 

destructor is used for destroy the objects.

  Was this answer useful?  Yes

kavitha

  • Jul 26th, 2006
 

desturctor is to destory objects.

this is denoted by '~'.

for eg:

class  alpha

{

public:

read(int);

disp();

~alpha();

};

void alpha::read()

{

cout<<"Enter i":

cin>>i;

}

void alpha::~alpha(int i)

{

i--;

cout<<i;

}

  Was this answer useful?  Yes

KishoreKNP

  • Dec 2nd, 2009
 

Destructor is a special member function of a class, which is called automatically by the compiler when the object is getting destroyed. In general we write the code here to cleanup the resources that are used by the class, like delete the memory, close the file handles, stop the thread etc, that is depending on the class that you are desiging.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions