Destructors caused program termination

When an object is created in your main () function, did its destructor call to terminate the program? I would suggest, since main () still has a scope (the whole program), but I just wanted to make sure.

+3
source share
2 answers

It depends on how your program ends. If it ends with a main return (either with an explicit return, or with a drop in the end), then yes, any automatic objects will basically be destroyed.

But if your program terminates by calling exit (), then the main thing does not go out of scope, and no automatic objects will be destroyed.

+15
source

main() . , . , , , . .

+3

Source: https://habr.com/ru/post/1726594/


All Articles