Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Question: 1 / 50

When are destructors for static objects called?

After main() exits or when exit() is called

Static objects are objects created within a class that can be accessed without creating an instance of the class. Static objects are destructed after main() exits or when exit() is called, because they have a longer lifetime than automatic objects, which are destructed when they go out of scope. B is incorrect because destructors for static objects are not called before main() enters. C is incorrect because the last instance of the object may not be the last to be destroyed. D is incorrect because destructors for static objects are automatically invoked when their lifespan ends.

Before main() enters

After the last instance of the object is destroyed

Never, they must be explicitly invoked

Next

Report this question