Check the following code,
Code:
class B
{
public:
	virtual void display()
	{
		cout<<"B"<<endl;
	}
};

class D : public B
{
public:
	void display()
	{
		cout<<"D"<<endl;
	}
};

void bar(auto_ptr<B> ptr)
{
	ptr->display();
}

int main(int argc, char* argv[])
{
    auto_ptr<D> ptr(new D);

	bar(ptr);
	return 0;
}
Actually it won't compile. I wonder how to make it work? Thanks.