Casting custom shared_ptr object
For doing:

shared_ptr&lt;Base_class&gt; b_ptr;
shared_ptr&lt;Child_class&gt; ptr(b_ptr);


you have to use another constructor. If you take a look on this Example of shared_ptr implementation, you can see:

template&lt;class U&gt; shared_ptr(const shared_ptr&lt;U&gt;&amp; s) ...


That's exactly the constructor, that takes shared_ptr of different type .

And similarly for assigment operator.