[comp.lang.c++] virtual base class problems

lars@island.COM (Lars Nyman) (02/05/91)

The following code using a virtual base class causes CFront to complain
(Sun C++ 2.0, and MPW C++ 3.1, both which are based on CFront 2.0).

IS this indeed a CFront bug, and does anybody know if it is fixed/will be fixed
in later versions of CFront (> 2.0) ?

// -------------------------------------------------
//#define INHERIT public
#define INHERIT virtual public

class TOne
{
 public:
    virtual void foo() {};
};

class TTwo : virtual public TOne
{
 public:
    void foo() {};
};

class TThree : INHERIT TTwo {};
class TFour  : INHERIT TThree {};
class TFive  : public TFour {};
class TSix   : public TFive {};
class TSeven : public TSix
{
 public:
    void bar() { foo(); };
};

//----------------------------------

CC foo-bug.cc
CC  foo-bug.cc:
"foo-bug.cc", line 24: error: ambiguous TTwo::foo() and TOne::foo() (different s
ub-objects)
"foo-bug.cc", line 24: error: ambiguous TTwo::foo() and TOne::foo() (different s
ub-objects)
"foo-bug.cc", line 24: error: ambiguous TTwo::foo() and TOne::foo() (different s
ub-objects)
3 errors