Here\'s what I\'m trying to do (this code doesn\'t work):
class Base
{
virtual Base *clone() { return new Base(this); }
virtual void ID() { printf(\"
Your example is incorrect and will not compile. Specifically this line:
Base bp = &d;
That may also be the root cause of your problem (you may be slicing your object), but I can't tell for certain without seeing working code.
You also have a problem where your two classes are not related (did you mean to write class Derived : public Base?)