74a Subj : Re: Can you mimic atexit() for class functions? To : borland.public.cpp.borlandcpp From : "Benjamin Pratt" Date : Wed Oct 08 2003 09:08 pm This may be the order BC destructs its objects, but I'm pretty sure that the standard does not define a destruction order, as Jeff stated. Please point me to the reference in the standard if I'm wrong. (It would be nice if I am wrong, since cleanup would be easier) "Ed Mulroy [TeamB]" wrote in message news:3f84121d@newsgroups.borland.com... > Yes there is an order. > > Class instances which are declared globally will have their destructor > called at the end of the program. > > Class instances which are allocated at runtime with new will have their > destructor called when delete is called for them. > > Class instances declared as local variables within a function will have > their destructor called when the function returns. > > Class instances returned as temporary instances from a function will have > their destructor called after the calling line is finished. > > So if you declare a global instance of a class then its destructor will be > called when the program ends. > > This has nothing to do with when a DLL would be unloaded. That is a > different subject. > > . Ed > > > Jeff Kish wrote in message > > news:6928ovsifnp973naqmk2l9k18jdfmnlf9n@4ax.com... > > > > Hey, don't forget, I don't thinkg there is any guarantee as far as the > > order of creation/destruction goes for static/global objects. > > I'm right, aren't I? Also the order of dlls and how they get shut down > > is unpredictable also, isn't it? I think this makes final cleanup > > painful sometimes. > > I appreciate any clarification/tutorial/"you ought to know better" > > type information here. > > . 0