What is destructor give example?



What is destructor give example?..

Answer / Vivek Kumar Tripathi

A destructor is a special member function of a class that is called when an object goes out of scope or when the delete operator is used on a pointer to the object. It is used to clean up any resources (like memory or files) that were allocated by the object. An example in C++ would be: class MyClass {ntMyClass() {ntt// cleanup code herent}n};

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOPS Interview Questions

What are the access specifiers avaible in c++?

4 Answers  


what is object slicing

3 Answers   TCS,


Program to check whether a word is in all capital letters

1 Answers  


What is a superclass in oop?

1 Answers  


what is main difference between object oriented object base

2 Answers   Wipro,


What is the default size allocated for array in the statement if size not specified " int a[] "

4 Answers   CTS,


How compiler selects(internally) required overridden function in inheritance?

2 Answers   CSC, Infinite Computer Solutions,


What is difference between multiple inheritance and multilevel inheritance?

1 Answers  


Is oop better than procedural?

1 Answers  


How to call a non virtual function in the derived class by using base class pointer

4 Answers   HCL,


How would you stop a class from class from being derived or inherited.

18 Answers   Ness Technologies,


How many types of access specifier in c# and vb.net?

1 Answers   Infosys,


Categories