when reading \"Beyond the C++ Standard Library: An Introduction to Boost \" ,I got a very interesting example:
class A
{
public:
virtual void sing()=0;
Surprisingly, the key here is not boost::shared_ptr destructor but its constructor(s).
If you look into boost/shared_ptr.hpp, you will see that shared_ptr does not 'simply' have a constructor expecting a T * but :
template
explicit shared_ptr( Y * p );
In //3 when you construct a boost::shared_ptr from a B *, no conversion to A * takes place, and the shared_ptr internals are built with the actual B type. Upon destruction of the object, deletion occurs on a B pointer (not through a base class pointer).