Removing Inheritance Reated Code

Asked By 0 points N/A Posted on -
qa-featured

I need to implement many derived classes with different constant member data. Data processing should be in the base class, but I can not find an elegant way to access the derived data. The following code works, but I do not really like it. The code must be run in a small integrated environment. Therefore, using full or shifted libraries such as Boost is not an option. How can I remove the inheritance related code?

SHARE
Answered By 0 points N/A #318463

Removing Inheritance Reated Code

qa-featured

You do not need virtual objects or templates here. Just add a SomeInfo * pointer and its length to Base and provide a protected constructor to initialize it (and since there is no default constructor, you cannot forget to initialize it).Protecting the constructor is not a difficult requirement, but since the base is no longer an abstract base class, the constructor’s protection prevents instantiation of the base.

Login/Register to Answer

Related Questions