Topic: Multiple Inheritance & Ambiguity
Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Mon, 1 Aug 1994 06:57:19 GMT Raw View
In article <IMMEL.94Jul25154936@chord.centerline.com> immel@chord.centerline.com (Mark Immel) writes:
>
>Folks --
>
> Can anyone tell me *where* the standard (May WP, preferably) says that
> the following code is illegal. I think it should be illegal; so do some
> compilers. Cfront, does not. The relevant section of the WP seems to
> be 10.2, but the answer doesn't quite seem to be there.
>
>class A
>{
>public:
> int i;
>};
>
>class B : virtual public A {
>};
>
>class C1 : public B
>{
>};
>
>class C2 : public B
>{
>};
>
>class D : public C1, public C2
>{
> D() { B::i; }
>};
>
> The reference to B::i is (IMO) ambiguous, since D has two B's as base
> classes. However, D has only one i anyplace, so Cfront says it's OK. The
> only thing I can find in the WP 10.2 is:
>
> "An explicit or implicit conversion from a pointer to or an lvalue of a
> derived class to a pointer to a reference to one of its base classes must
> unambiguously refer to a unique object representing the abse class."
>
> An example follows which contains lots of address-of operators and so forth.
> If this is meant to cover my example, it should be explicit. It also says
> earlier in 10.2 that the following *IS* legal (as it should be):
>
> D() {i;}
>
> As always, you may email me at immel@centerline.com and I'll follow up.
>
>-- Mark Immel
> immel@centerline.com
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd,
81A Glebe Point Rd, GLEBE Mem: SA IT/9/22,SC22/WG21
NSW 2037, AUSTRALIA Phone: 61-2-566-2189
Author: immel@chord.centerline.com (Mark Immel)
Date: 25 Jul 1994 19:49:31 GMT Raw View
Folks --
Can anyone tell me *where* the standard (May WP, preferably) says that
the following code is illegal. I think it should be illegal; so do some
compilers. Cfront, does not. The relevant section of the WP seems to
be 10.2, but the answer doesn't quite seem to be there.
class A
{
public:
int i;
};
class B : virtual public A {
};
class C1 : public B
{
};
class C2 : public B
{
};
class D : public C1, public C2
{
D() { B::i; }
};
The reference to B::i is (IMO) ambiguous, since D has two B's as base
classes. However, D has only one i anyplace, so Cfront says it's OK. The
only thing I can find in the WP 10.2 is:
"An explicit or implicit conversion from a pointer to or an lvalue of a
derived class to a pointer to a reference to one of its base classes must
unambiguously refer to a unique object representing the abse class."
An example follows which contains lots of address-of operators and so forth.
If this is meant to cover my example, it should be explicit. It also says
earlier in 10.2 that the following *IS* legal (as it should be):
D() {i;}
As always, you may email me at immel@centerline.com and I'll follow up.
-- Mark Immel
immel@centerline.com