c++ - How to avoid changing every child constructor when parent constructor changes -


say have following (c++)

class parent {      parent(foo f){}; }  class child : public parent {     child(foo f, bar b)         : parent(f)     {}; } ... // , whole bunch of other children, calling parent constructor 

suppose need add new parameter parent constructor

parent(foo f, baz z){}; 

then have change every single child class following

child(foo f, baz z, bar b)     : parent(f, z) {}; 

is there anyway can avoid having change every single child class?

guess might related this, how avoid repetitive constructor in children suggests must change every child class.

if so, there languages / design patterns make such change less painful?

if new argument parent constructor mandatory there no choice, have update child classes constructors.

but if new argument not mandatory, add new parent constructor overloaded constructor, or use default value new argument.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -