guillo@lahire.serma.cea.fr writes: > What > about a gargabe collector? I can suggest looking at libsigc++ 1.2 (not 1.0) http://libsigc.sourceforge.net/ or download from http://sourceforge.net/projects/libsigc/ Besides a nice signal/slot mechanism, this library provides a templated reference counted smart pointer class: SigC::Ptr<>. You use it like: class MyType : public SigC::Object { ... }; { SigC::Ptr<MyType> a = SigC::manage(new MyType); a->DoSomething(); // access just like (*a).DoSomethingElse(); // a normal pointer .... } After this block, "a" goes out of scope, the reference count goes to zero and the instance of MyType is deleted. If there was an external SigC::Ptr<MyType> that also held a pointer to this object, it would survive. So, if all your classes hold instances of shared objects in a SigC::Ptr<> then you get automatic garbage collection. -Brett.
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:14 MET