Boost logo

Boost Users :

From: Joshua Little (ljoshua_at_[hidden])
Date: 2004-02-04 09:42:04


Michele Galante wrote:

>> So I have something like this:
>>
>> std::vector<boost::shared_ptr<Base> > BaseVector;
>>
>> void add(boost::shared_ptr<Base>& newOne) {
>> BaseVector.push_back(newOne);
>> }
>>
>> and I call it like this usually :
>> boost::shared_ptr<Derived> p(new Derived);
>> add(p);
>>
>
> I think the problem is you take a reference to the shared_ptr. Try
> this way:
>
> void add(boost::shared_ptr<Base> newOne) {
> BaseVector.push_back(newOne);
> }
>
Ah, that seemed to have fixed the problem.
Thank you,
Joshua.


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