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(\"
With Base bp = &d;
Base bp = &d;
You've "sliced" d, so to the compiler, bp really is only of type Base, which is why when you call bp->clone() the compiler calls Base::clone(); and bp2->ID() prints BASE.
d
bp
Base
bp->clone()
Base::clone();
bp2->ID()
BASE
Base& bp = d; will do what you want.
Base& bp = d;