← Quiz: C++ Classes and Objects: all 10 questions
Quiz: C++ Classes and Objects · Question 2 of 10
When does a destructor run?
When does a destructor run?
- A.When you call delete only
- B.Automatically when the object is destroyed (e.g. it goes out of scope)
- C.When the program starts
- D.Never automatically
Answer & explanation
Correct answer: Automatically when the object is destroyed (e.g. it goes out of scope)
Local objects are destroyed at the end of their scope.
Can you get the rest right without peeking?
Take the timed Quiz: C++ Classes and Objects quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →