albert@ccwf.cc.utexas.edu (Albert Wu) (11/26/90)
Dear all: I use ATT CC 2.0. I have a question about using return vs. exit() in the main function. I found that the destructor is not called automatically when I use exit, but it is called if I use return. For example, in the following case: #include <stream.h> class Junk { public: Junk(){ cout << "Constructor called.\n";} ~Junk() { cout << "Destructor called.\n"; } }; main() { Junk idol; exit(1); return 1; } the destructor is not called. However, if I eliminate the exit(1); line, the destructor will be called. Did I do something wrong here ? Is this the way it should be ? Where can I pinpoint documentation about this issue ( difference between exit and return ) ? Pls reply using email also because I don't read the newsgroup regularly. Thanks ahead. -- Albert Wu.