71b Subj : Re: Can you mimic atexit() for class functions? To : borland.public.cpp.borlandcpp From : Jeff Kish Date : Wed Oct 08 2003 09:56 am On Tue, 7 Oct 2003 23:08:32 -0400, "Ed Mulroy [TeamB]" wrote: >Classes are gone by the time atexit does its thing. > >An AddCallback function shouldn't be too difficult to write, but what you >describe sounds as if it is supposed to be called at the end of the program. >The way to do that with classes is to place either the code for what you >want or the code for the call in the class destructor. If it needs to run >at the end of the program, then write a class and declare a global instance >of it and put the code in the destructor. > >. Ed > >> gary wrote in message >> news:3F837C67.3040604@cordelli.net... >> >> just wondering if it is possible to have a member function in various >> (different) classes, but provide a single additional class that defines >> some kind of "AddCallback()" function that each object of the various >> other classes can call in order to add their own member function to a >> callback list so that the single additional class can invoke the list of >> added callbacks each in turn ? >> >> this is sort of like the way atexit() works in C, but in that case it is >> easy to just define every added callback as "void (*pfn)()", whereas in 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. Thanks Jeff Kish . 0