public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* abstract base classes & MI
@ 1999-02-19 14:04 Charles Kerr
       [not found] ` < 19990219160356.A18159@osserver1.nssl.noaa.gov >
  1999-02-28 22:53 ` Charles Kerr
  0 siblings, 2 replies; 8+ messages in thread
From: Charles Kerr @ 1999-02-19 14:04 UTC (permalink / raw)
  To: egcs, egcs-bugs

Using egcs-2.93.06 (the 1999/02/08 snapshot), the code:

     struct A_interface {
        virtual void foo ( ) = 0;
     };
     struct A_impl {
        virtual void foo ( );
     };
     struct B_interface: public A_interface {
        virtual void bar ( ) = 0;
     };
     struct B_impl : public A_impl, public B_interface {
        virtual void bar ( );
     };
     struct C: public B_impl {
        void asdf ( ) {
           foo ( );
        }
     };

yields the error:

     Foo.C: In method `void C::asdf()':
     Foo.C:15: request for member `foo' is ambiguous in multiple inheritance lattice

I don't see the ambiguity.  Does egcs really think I want to invoke the pure method? :)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: abstract base classes & MI
       [not found] ` < 19990219160356.A18159@osserver1.nssl.noaa.gov >
@ 1999-02-19 15:15   ` Martin v. Loewis
  1999-02-28 22:53     ` Martin v. Loewis
  0 siblings, 1 reply; 8+ messages in thread
From: Martin v. Loewis @ 1999-02-19 15:15 UTC (permalink / raw)
  To: ckerr; +Cc: egcs, egcs-bugs

> I don't see the ambiguity.  Does egcs really think I want to invoke
> the pure method? :)

Yes. Pureness doesn't matter in name lookup. If you want to remove the
ambituity, you can call the method for the A_impl base object:

           ((A_impl*)this)->foo ( );

Regards,
Martin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: abstract base classes & MI
  1999-02-19 15:15   ` Martin v. Loewis
@ 1999-02-28 22:53     ` Martin v. Loewis
  0 siblings, 0 replies; 8+ messages in thread
From: Martin v. Loewis @ 1999-02-28 22:53 UTC (permalink / raw)
  To: ckerr; +Cc: egcs, egcs-bugs

> I don't see the ambiguity.  Does egcs really think I want to invoke
> the pure method? :)

Yes. Pureness doesn't matter in name lookup. If you want to remove the
ambituity, you can call the method for the A_impl base object:

           ((A_impl*)this)->foo ( );

Regards,
Martin


^ permalink raw reply	[flat|nested] 8+ messages in thread

* abstract base classes & MI
  1999-02-19 14:04 abstract base classes & MI Charles Kerr
       [not found] ` < 19990219160356.A18159@osserver1.nssl.noaa.gov >
@ 1999-02-28 22:53 ` Charles Kerr
  1 sibling, 0 replies; 8+ messages in thread
From: Charles Kerr @ 1999-02-28 22:53 UTC (permalink / raw)
  To: egcs, egcs-bugs

Using egcs-2.93.06 (the 1999/02/08 snapshot), the code:

     struct A_interface {
        virtual void foo ( ) = 0;
     };
     struct A_impl {
        virtual void foo ( );
     };
     struct B_interface: public A_interface {
        virtual void bar ( ) = 0;
     };
     struct B_impl : public A_impl, public B_interface {
        virtual void bar ( );
     };
     struct C: public B_impl {
        void asdf ( ) {
           foo ( );
        }
     };

yields the error:

     Foo.C: In method `void C::asdf()':
     Foo.C:15: request for member `foo' is ambiguous in multiple inheritance lattice

I don't see the ambiguity.  Does egcs really think I want to invoke the pure method? :)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: abstract base classes & MI
  1999-02-19 16:35 Mike Stump
       [not found] ` < 199902200035.QAA29830@kankakee.wrs.com >
@ 1999-02-28 22:53 ` Mike Stump
  1 sibling, 0 replies; 8+ messages in thread
From: Mike Stump @ 1999-02-28 22:53 UTC (permalink / raw)
  To: ckerr, egcs-bugs, egcs

> Date: Fri, 19 Feb 1999 16:03:56 -0600
> From: Charles Kerr <ckerr@enterprise.nssl.noaa.gov>
> To: egcs@egcs.cygnus.com, egcs-bugs@egcs.cygnus.com

> Using egcs-2.93.06 (the 1999/02/08 snapshot), the code:

>      struct A_interface {
>         virtual void foo ( ) = 0;
>      };
>      struct A_impl {
>         virtual void foo ( );
>      };
>      struct B_interface: public A_interface {
>         virtual void bar ( ) = 0;
>      };
>      struct B_impl : public A_impl, public B_interface {
>         virtual void bar ( );
>      };
>      struct C: public B_impl {
>         void asdf ( ) {
>            foo ( );
>         }
>      };

> yields the error:

>      Foo.C: In method `void C::asdf()':
>      Foo.C:15: request for member `foo' is ambiguous in multiple inheritance lattice

> I don't see the ambiguity.

Let me explan on what others have said some...

Which subobject did you want the virtual foo valled with?  A_impl or
a_interface?  How does the code indicate that?  (It doesn't.)  Put in
a virtual base for A_impl and A_interface and link A_impl to
A_interface and it'll work as written.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: abstract base classes & MI
  1999-02-19 17:14   ` Charles Kerr
@ 1999-02-28 22:53     ` Charles Kerr
  0 siblings, 0 replies; 8+ messages in thread
From: Charles Kerr @ 1999-02-28 22:53 UTC (permalink / raw)
  To: Mike Stump; +Cc: ckerr, egcs-bugs, egcs

On Fri, Feb 19, 1999 at 04:35:06PM -0800, Mike Stump wrote:

[diamond-shaped inheritance snipped]

> > I don't see the ambiguity.
> 
> Which subobject did you want the virtual foo valled with?  A_impl or
> a_interface?  How does the code indicate that?  (It doesn't.)  Put in
> a virtual base for A_impl and A_interface and link A_impl to
> A_interface and it'll work as written.

Whoops; the code I wrote had "A_impl : public A_interface" but apparently
lost it somewhere down the line.  Making the inheritance virtual was the
step I was missing.  Thanks, and sorry for using this list for a C++ Q&A. 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: abstract base classes & MI
       [not found] ` < 199902200035.QAA29830@kankakee.wrs.com >
@ 1999-02-19 17:14   ` Charles Kerr
  1999-02-28 22:53     ` Charles Kerr
  0 siblings, 1 reply; 8+ messages in thread
From: Charles Kerr @ 1999-02-19 17:14 UTC (permalink / raw)
  To: Mike Stump; +Cc: ckerr, egcs-bugs, egcs

On Fri, Feb 19, 1999 at 04:35:06PM -0800, Mike Stump wrote:

[diamond-shaped inheritance snipped]

> > I don't see the ambiguity.
> 
> Which subobject did you want the virtual foo valled with?  A_impl or
> a_interface?  How does the code indicate that?  (It doesn't.)  Put in
> a virtual base for A_impl and A_interface and link A_impl to
> A_interface and it'll work as written.

Whoops; the code I wrote had "A_impl : public A_interface" but apparently
lost it somewhere down the line.  Making the inheritance virtual was the
step I was missing.  Thanks, and sorry for using this list for a C++ Q&A. 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: abstract base classes & MI
@ 1999-02-19 16:35 Mike Stump
       [not found] ` < 199902200035.QAA29830@kankakee.wrs.com >
  1999-02-28 22:53 ` Mike Stump
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Stump @ 1999-02-19 16:35 UTC (permalink / raw)
  To: ckerr, egcs-bugs, egcs

> Date: Fri, 19 Feb 1999 16:03:56 -0600
> From: Charles Kerr <ckerr@enterprise.nssl.noaa.gov>
> To: egcs@egcs.cygnus.com, egcs-bugs@egcs.cygnus.com

> Using egcs-2.93.06 (the 1999/02/08 snapshot), the code:

>      struct A_interface {
>         virtual void foo ( ) = 0;
>      };
>      struct A_impl {
>         virtual void foo ( );
>      };
>      struct B_interface: public A_interface {
>         virtual void bar ( ) = 0;
>      };
>      struct B_impl : public A_impl, public B_interface {
>         virtual void bar ( );
>      };
>      struct C: public B_impl {
>         void asdf ( ) {
>            foo ( );
>         }
>      };

> yields the error:

>      Foo.C: In method `void C::asdf()':
>      Foo.C:15: request for member `foo' is ambiguous in multiple inheritance lattice

> I don't see the ambiguity.

Let me explan on what others have said some...

Which subobject did you want the virtual foo valled with?  A_impl or
a_interface?  How does the code indicate that?  (It doesn't.)  Put in
a virtual base for A_impl and A_interface and link A_impl to
A_interface and it'll work as written.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1999-02-28 22:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-19 14:04 abstract base classes & MI Charles Kerr
     [not found] ` < 19990219160356.A18159@osserver1.nssl.noaa.gov >
1999-02-19 15:15   ` Martin v. Loewis
1999-02-28 22:53     ` Martin v. Loewis
1999-02-28 22:53 ` Charles Kerr
1999-02-19 16:35 Mike Stump
     [not found] ` < 199902200035.QAA29830@kankakee.wrs.com >
1999-02-19 17:14   ` Charles Kerr
1999-02-28 22:53     ` Charles Kerr
1999-02-28 22:53 ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).