Using exit() in destructor of a class having static object, doesn't end up in an infinite loop as expected
问题 I came across this in chapter 10, Thinking in C++ vol.1 by Bruce Eckel. Destructors for static objects (that is, all objects with static storage, not just local static objects as in the example above) are called when main( ) exits or when the Standard C library function exit( ) is explicitly called. In most implementations, main( ) just calls exit( ) when it terminates. This means that it can be dangerous to call exit( ) inside a destructor because you can end up with infinite recursion I