by Sebb767 · 2y ago · 0 comments
Rectangle *r = new Rectangle();
r->draw(); // calls Rectangle::draw(GREEN)
Shape *s = *r;
s->draw(): // calls Rectangle::draw(RED)
Intuitively, you would not expect that a function changes its behavior when it's called from a pointer of a different type. I can easily see this leading to very a fun-to-reproduce-kind of bug.