[comp.sys.mac.programmer] 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

rae@gpu.utcs.toronto.edu (Reid Ellis) (02/08/91)

Lars Nyman <lars@island.COM> writes:
>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) ?

It is a bug.  It isn't fixed.  I, too, bashed my head against this one
for several days.

As a result I now have a SADE procedure to print out virtual method
tables, complete with [mangled] method names.  Anyone want it?

					Reid
--
Reid Ellis  176 Brookbanks Drive, Toronto ON, M3A 2T5 Canada
rae@utcs.toronto.edu        ||  rae%alias@csri.toronto.edu
CDA0610@applelink.apple.com ||             +1 416 446 1644