Let a library containing the following class hierarchy :
class LuaChunk
{
};
class LuaExpr : public LuaChunk
{
};
class LuaScript : public LuaChunk
{
};
Now I would like to use this library in my application by extending these two classes :
class AppLuaExpr : public LuaExpr
{
private:
Foo * someAppSpecificMemberFoo;
Bar * someAppSpecificMemberBar;
};
class AppLuaScript : public LuaScript
{
private:
Foo * someAppSpecificMemberFoo;
Bar * someAppSpecificMemberBar;
};
The problem here is that, if I have many members, each of them having its own pair of getter/setter, it's going to generate a lot of code duplication.
Is there a way, that does not use multiple inheritance (which I want to avoid) to put in common the application-specific stuff contained in both AppLuaExpr and AppLuaExpr ?
I've taken a look on the existing structural design patterns listed on Wikipedia, but it doesn't seem like any f these is adapted to my issue.
Thank you.