You can use virtual inheritance in combination with the default implementation base class to encapsulate the default base behavior and only have it inherited by the specific classes you want, for example:
using namespace std;
class IBase
{
public:
virtual void BaseMethod1() = 0;
virtual void BaseMethod2() = 0;
};
class IEntity1 : virtual public IBase
{
public:
virtual void Entity1Method1() = 0;
virtual void Entity1Method2() = 0;
};
class BaseImpl : virtual public IBase
{
public:
virtual void BaseMethod1()
{
...
}
virtual void BaseMethod2()
{
...
}
}
class Entity1 : public IEntity1, public BaseImpl
{
public:
Entity1();
void Entity1Method1();
void Entity1Method2();
void Method1();
void Method2();
};
, , , . , . .
, :
template<typename TEntity, typename TBaseImpl>
class ConcreteEntity: public TEntity, public TBaseImpl
{
public:
ConcreteEntity() {}
};
class ConreteEntity1 : public ConcreteEntity<IEntity1, BaseImpl>
{
public:
ConreteEntity1();
void Entity1Method1();
void Entity1Method2();
void Method1();
void Method2();
};