I define two classes in C++, as follows:

class CBaseClass
{

}

class CDerivedClass : public CBaseClass
{

}

And want to implement a clone function as follows:

CBaseClass *Clone(const CBaseClass *pObject)
{
}

When an object of CDerivedClass is passed to Clone, then the function will also create a CDerivedClass object and return.
When an object of CBaseClass is passed to Clone, then the function will also create a CBaseClass object and return.

How to implement such a feature?