← BYTES
C++·Starter·Ref: 8.1.8
When is a class's destructor called?
Have a question about this video? Mention reference 8.1.8 when you contact us.
a.Only when the program explicitly calls it
b.Destructors do not exist in C++
c.Only for classes with virtual functions
d.Automatically when an object goes out of scope or is explicitly deleted, to release its resources
A destructor (named ~ClassName) runs automatically when an object's lifetime ends -- a local object going out of scope, or a heap object being delete'd -- giving the class a chance to release any resources it holds (memory, file handles, locks).
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES818#C