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.
Discussion:
3 comments Page 1 of 1.
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.
As far as I am concerned for normal objects destructors are called even when the program is terminated using exit function.
(1)
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.
It does not call destructors for automatic objects though.
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.
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.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers