Prev: C++ template base class' nested typedefs not visible in derived template class
Next: random number [0, 99]
From: Peter Dimov on 6 Feb 2006 05:12 random.sampling(a)gmail.com wrote: > Hello, > when I try to use atexit() from a C++ class, my compiler is giving me > an error. > > error C2664: 'atexit' : cannot convert parameter 1 from 'void (void)' > to 'void (__cdecl *)(void)' > > Is it possible to use atexit() with a C++ class member or only with > global functions? As other have already explained, no, atexit needs an ordinary function. However... > Thank you in advance, > Marco > > ///////////////// > > #include <cstdlib> > > namespace test > { > class foo > { > public: > foo(){}; > ~foo(){}; > void Killfoo() > {foo->~foo();} > void RegisterForDestruction() > {atexit(killFoo);} > }; > } .... I cannot pass the opportunity to suggest void RegisterForDestruction() { static boost::shared_ptr<foo> px( this, boost::mem_fn(&foo::killFoo) ); } as a substitute. :-) [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
First
|
Prev
|
Pages: 1 2 Prev: C++ template base class' nested typedefs not visible in derived template class Next: random number [0, 99] |