|
Boost Users : |
From: Stephen Torri (storri_at_[hidden])
Date: 2007-03-22 19:18:44
I am attempting to hunt down why I am getting a segmentation fault from
the boost::shared_ptr class. I know that it has to do with how I am
managing my shared pointers. That is creating and using them in
functions. I am reading the best practices web page and I have a
question about the best way to initialize a shared_ptr.
Normally I have a class like the following:
class A {
public:
typedef boost::shared_ptr<A> ptr_t;
A ( int input_value )
: value ( input_value )
{}
private:
int value;
};
Which I will use in another place:
class A_User {
public:
A_User ()
: m_a_ptr ( new A() )
{}
private:
A::ptr_t m_a_ptr;
};
Is this the correct way to initialize the A::ptr_t held in the A_User
class in its constructor?
Stephen
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