Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!decwrl!netcomsv!sjsumcs!horstman From: horstman@mathcs.sjsu.edu (Cay Horstmann) Newsgroups: comp.lang.c++ Subject: Re: How do I call destructors on ^C in TC++? Message-ID: <1991May28.225141.1451@mathcs.sjsu.edu> Date: 28 May 91 22:51:41 GMT References: <1991May24.045847.24401@colorado.edu> <1991May27.024810.2300@minyos.xx.rmit.oz.au> Organization: San Jose State University - Math/CS Dept. Lines: 18 In article <1991May27.024810.2300@minyos.xx.rmit.oz.au> s892992@minyos.xx.rmit.oz.au (Kendall Bennett) writes: >scholes@spot.Colorado.EDU (Genuine Bud Man) writes: > >> Please excuse me if this is a FAQ, or if I am missing something >>painfully obvious, but destructors don't seem to be called when >>the user hits ^C in Turbo C++. > > I am pretty sure that if you call the exit() standard library function it >calls the destructors for any AUTO variables, that is any instances that have >been allocated on the stack. If the class instance was allocted in the heap, >then it is up to the program to delete it - so I don't know how you would >handle this one. > Fat chance. No such thing will happen. When you call exit(), the stack just gets popped, the free store given back wholesale. I am not sure whether STATIC destructors are run. Someone here surely knows the answer. Cay