Although I should love the codeka answer, I can't help but imagine that the problem is with the declaration as a member attribute.
For something like GC-GC, I would probably use the Monoid pattern. All instances of the class are actually proxies of a Singleton (essentially), i.e. They all have the same state. Thus, no matter how many instances are created, they all point to the same resource.
If you do this to avoid circular references, I am afraid that this is not enough.
struct A { boost::shared_ptr<B> mB; }; struct B { boost::shared_ptr<A> mA; };
Matthieu M.
source share