by konstantinua00 · 2y ago · 0 comments
default parameters are caller's hint, it's even part of declaration - not definition (and it doesn't have to be the same in different files, it's not even ub - because it's literally hint for the caller when param isn't there)
"dynamic default parameters" would pin them to the function, which isn't the design
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.