C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 32)
32.
Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.
are called
are inherited
are not called
are created
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
3 comments Page 1 of 1.

Junaid said:   6 months ago
To ensure destructor is called we must have return 0 in main. It will give proper cleanup and destructor should also be called.

But if we use exit (0) instead of return 0 it performs cleanup such as I/o buffer and destructor will not be called. Abort() does the same.

Akshay said:   10 years ago
abort() exits your program without calling functions registered using atexit() first, and without calling objects.destructors first. exit() does both before exiting your program.

It does not call destructors for automatic objects though.

Paritosh said:   1 decade ago
What are autonomic objects?

As far as I am concerned for normal objects destructors are called even when the program is terminated using exit function.
(1)

Post your comments here:

Your comments will be displayed after verification.