Ace Your C++ Skills 2025 – Rock the ‘Thinking in C++’ Challenge!

Question: 1 / 565

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.

Get further explanation with Examzify DeepDiveBeta

Before main() enters

After the last instance of the object is destroyed

Never, they must be explicitly invoked

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy