My intention is to have some base class `CBaseClass` that, amongst other things, serves as a container to some members of type `CBaseMember`; then to derive a `CDerivedClass : public CBaseClass` that holds `CDerivedMember : public CBaseMember`.

I can't use a pointer to `CBaseMember` and initialize it with a `CDerivedMember` object in `CDerivedClass` because it's a multiple inheritance situation, `CDerivedMember` has an additional interface (a pure abstract base class) that is irrelevant to `CBaseClass` implementation but needs to be visible to `CDerivedClass`. Lots of dirty casting is something that I would very much like to avoid.

My solution to this problem was to make `CBaseClass` a template, like this:

```
//declaration
template <class Member>
CBaseClass
{
protected:
    virtual void GenericMethod();
    virtual void VirtualMethod() = 0;

    Member* member;
};

//definition
template <class Member>
void CBaseClass<Member>::GenericMethod()
{
    member->SomeMemberMethod();
}

```

and then to inherit `CDerivedClass` from it, like this:

```
//declaration
CDerivedClass : public CBaseClass<CDerivedMember>
{
protected:
    virtual void VirtualMethod();
};

//definition
void CDerivedClass::VirtualMethod()
{
    member->SomeDerivedMethod();
}

```

Predictably, this doesn't work (`CBaseClass<CDerivedMember>::GenericMethod()` is unresolved, for obivious reasons), but unfortunatly I don't know how to change my code to mean what I intend for it to mean.

Can anyone please explain how those things are done properly - or suggest another solution for my problem?

Thanks!