The only possibility for Class_B is to actually inherit from Class_A ; in this case, the constructor for Class_A will be called from the derived class itself. But since this also involves changing the code generator or entering the code generator, you can change it to add an additional constructor to Class_B .
If you really cannot change the code generator or input it in such a way as to lead to the generation of an additional constructor, but you can change Class_A and Class_C , then there are two possible solutions:
The simplest is to use delayed initialization; add a
Class_A function that takes the appropriate parameters and does initialization after the constructor completes. While the simplest one, this method can be used only if
Class_A can be used for support as well as if all members of the support are
Class_A with semantics, so after assignment it has the same result as building using arguments you you give (i.e. there are no reference members, no non-communicable members, no
const , etc.). Alternatively, you can put all the functionality (or at least data members) of
Class_A in a separate class and have
Class_A derive from this class practically.
Class_C will then call the constructor of this new class.
source share