What happens if you do not define a destructor in the class declaration? Nothing
ID: 3727156 • Letter: W
Question
What happens if you do not define a destructor in the class declaration?
Nothing, a destructor is not always needed
You get an error message when you attempt to compile your program
One is created for you that does absolutely nothing
One is created for you that deallocated pointers as necessary, but otherwise it would do nothing
a.Nothing, a destructor is not always needed
b.You get an error message when you attempt to compile your program
c.One is created for you that does absolutely nothing
d.One is created for you that deallocated pointers as necessary, but otherwise it would do nothing
Explanation / Answer
Destructors are needed to be defined in the following situations
1) when the object gets destroyed and if there is need to perform other actions like deallocating memory for variable allocated using new operator rather than destroying all the class members
2) if there is need to destroy objects through base class pointer
So if above situations are not required, then option (a) is correct answer
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.