What is the difference between a constructor and a destructor in C++?



What is the difference between a constructor and a destructor in C++?..

Answer / nashiinformaticssolutions

While a destructor is used to remove class objects, a constructor aids in initializing them. Both are invoked automatically: the constructor allocates memory instantly upon creating a new object, and the destructor deals with memory when destroying an existing one.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

0 Answers  


Write a program using display() function which takes two arguments.

0 Answers  


What is Namespace?

5 Answers   HCL, Samsung,


What causes a runtime error c++?

0 Answers  


Explain polymorphism?

0 Answers  






Is c better than c++?

0 Answers  


How to give an alternate name to a namespace?

0 Answers  


What is the Difference between "C structure" and "C++ structure"?

12 Answers  


implement stack using stack.h headerfile functions

1 Answers   Exilant, GMG, Subex, University,


What does getch() do according to the ANSI C++ standard a) Reads in a character b) Checks the keyboard buffer c) Nothing in particular (Its not defined there)

0 Answers  


What are friend functions in C++?

0 Answers   BlackRock,


What do you mean by abstraction in C++?

1 Answers  


Categories