two base classes

Hi,

Say I have a base classe that inherits from another base class, then I derive another class from them. What is the proper way. For example:

class BaseForText
{
public:
virtual void SetText(const TCHAR *text)=0;
}

class BaseForTextAndZammo : public BaseForText
{
public:
virtual void SetZammo(const TCHAR *zammo)=0;
}

class MyTextClass : public BaseForText
{
// here I'd do my constructor and settext
}

class MyTextAndZammo : public MyTextClass
{
// here I'd do my constructor and setzammo
};

But if you create MyTextAndZammo object and assign to a BaseForTextAndZammo variable then it doesn't work right.

So how would you do it so you down't have to duplicate the code from MyTextClass?

TIA!!
Last edited on
Of course, MyTextAndZammo is derived from MyTextClass, which is derived from BaseForText, and not BaseForTextAndZammo. Do you want multiple inheritance? C++ supports that.
I wanted to reuse the code already done in MyTextClass without it being duplicated in MyTextAndZammo.
Topic archived. No new replies allowed.