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


Please Help Members By Posting Answers For Below Questions

Comment on assignment operator in c++.

888


Explain the term memory alignment?

916


What is an arraylist c++?

904


Can notepad ++ run c++?

739


Can you please explain the difference between overloading and overriding?

822


How would you implement a substr() function that extracts a sub string from a given string?

783


Which programming language's unsatisfactory performance led to the discovery of c++?

1058


Explain terminate() function?

801


Explain function overloading

784


When must you use a pointer rather than a reference?

800


What is a manipulator in c++?

939


Does c++ have arraylist?

742


What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?

846


Explain operator overloading.

817


If you don’t declare a return value, what type of return value is assumed?

738