Boost logo

Boost Users :

From: TOL Tsagarakis Manos (mtsagara_at_[hidden])
Date: 2007-05-10 14:17:57


I believe you can do what you want like this:

 

#include <boost\shared_ptr.hpp>

#include <boost\weak_ptr.hpp>

 

class A;

class B;

 

typedef boost::shared_ptr<A> spA;

typedef boost::shared_ptr<B> spB;

typedef boost::weak_ptr<A> wpB;

 

class A

{

   // ...

   spB m_b;

};

 

 

class B

{

    wsB m_wpParent;

    // ...

    std::vector<spA> m_a;

};

 

 

I hope this helps,

Manos

 

 

 

 

 

From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Olivier Tournaire
Sent: Thursday, May 10, 2007 9:08 PM
To: boost-users_at_[hidden]
Subject: [Boost-users] Smart pointers

 

Hi all

Suppose I have two classes A and B like those ones :

Typedef

class A
{
   // ...
   B *m_b;
};

class B
{
   // ...
   std::vector<A *> m_a;
};

m_b is used to know who is the parent of the object.

I would like to use smart pointers. How can I do this ?

Thanks in advance

-- 
Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des noyaux.
Courage. 



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net