I want to add some basic information to a derived class on which it can be based. A derived class does not have to worry about initializing this information; it should only be there.
This in itself could easily be obtained through inheritance. But the problem is that the base class itself does not know the meaning. Instead, they should be passed as a parameter. However, since the derived class does not have to worry about this, tunneling parameters through the derived constructor, which calls the base constructor with it, is not an option.
The only solution I can think of is to make the information available statically so that the base class can get it without help. But I would like to avoid this.
Is there a way to first create and initialize a base class and then expand the instance to a derived type? If not, how can I achieve this order of creation and dependencies using the available C ++ features?
#include <string>
source share