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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -