From: Christian Kreibich (kreibich_at_[hidden])
Date: 2002-04-05 14:06:25
Larry Evans wrote:
> Maybe this is nitpicking, but in the above, I see a B instance pointing to an A instance, but I don't see
> how an A instance points to a B. I only see a virtual A function creating a B pointer.
> Also, B::ptr is not declared when used in A's declaration.
> Now if you've actually got A <--> B, then couldn't you make one typedef a weak_ptr and the other
> a "strong" pointer, i.e. a shared_ptr<X>?
> If not, then you'd have to use one of the circular pointer solutions already posted elsewhere in boost.
> In particular, Gre Colvin's cyclic_ptr located, at least last year, at libs/smart_ptr/smarttest.zip.
Larry, I was probably not clear in the explanation of my problem, your
answer goes way beyond my problem :) I was not worried about circular
pointer structures, just build dependencies.
Say I have two compilation units, one for class A, the other for class
B, as illustrated above. Using the usual #ifndef/#define/#endif
semantics, class A depends on the typedef of B::ptr, and class B depends
on the A::ptr typedef. How can I get this to compile without getting a
parse error because it's still unknown what A::ptr or, respectively,
B::ptr, is? Is there a way to get this to build, while keeping the
smartpointer typedefs withing the classes?
Hope this is clearer.
-- ________________________________________________________________________ http://www.whoop.org
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk