$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Russell Hind (yg-boost-users_at_[hidden])
Date: 2003-06-20 02:21:11
Drew wrote:
> void Fn(ParentPtr& pObj)
> {
> pObj = ParentPtr(new Parent());
> pObj->m_value = 10;
> }
>
> If I pass the parent pointer, it compiles and works fine. If I pass
> the derived pointer I get:
> > error C2664: 'Fn' : cannot convert parameter 1 from 'DerivedPtr'
> to 'ParentPtr &'
>
You can't assign to a shared_ptr (assuming ParentPtr is a shared_ptr as
the moderator has suggested). You have to call reset on it
e.g.
pObj.reset(new Parent());
HTH
Russell