← Quiz: C++ Interview Questions: all 10 questions
Quiz: C++ Interview Questions · Question 10 of 10
What does delete do that free does not?
What does delete do that free does not?
- A.Nothing; they are the same
- B.It calls the object's destructor before releasing the memory
- C.It sets the pointer to nullptr
- D.It works only on arrays
Answer & explanation
Correct answer: It calls the object's destructor before releasing the memory
new/delete call constructors and destructors; malloc/free only manage raw bytes.
Can you get the rest right without peeking?
Take the timed Quiz: C++ Interview Questions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →