What is the difference between a constructor and a destructor in C++?
Answer Posted / 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 View All Answers
What is the difference between public and private data members?
Why can templates only be implemented in the header file?
What is the difference between a reference and a pointer?
Write a code/algo to find the frequency of each element in an array?
Explain about Virtual Function in C++?
What is type of 'this' pointer? Explain when it is get created?
What is the use of structure in c++?
What is the function to call to turn an ascii string into a long?
How does code-bloating occur in c++?
When should overload new operator on a global basis or a class basis?
What is auto used for in c++?
Is c++ the hardest programming language?
Are vectors faster than arrays?
What it is and how it might be called (2 methods).
What is the use of object in c++?