Topic: ambiguous typedef


Author: TABATA Tomohira <loba@k2.t.u-tokyo.ac.jp>
Date: 1996/01/29
Raw View
Hi, there.

Can't I use this declaration successfully?

   class T1 {
   public:
      typedef T1 myclass;
   };

   class T2 {
   public:
      typedef T2 myclass;
   };

   class T3 : public T1, T2 {
   public:
      typedef T3 myclass;
   };

By gcc-2.7.1 this cannot be compiled because of "request for member
`myclass' is ambiguous" on the line "typedef T3 myclass;".

I cannot find description on this matter in DWP.

This quetion was indicated originally by
yamada@ch0sw001.bkc.ritsumei.ac.jp.

------
   Tomohira Tabata loba@k2.t.u-tokyo.ac.jp
   Department of Mathematical Engineering and Information Physics,
   Faculty of Engineering, University of Tokyo, Japan
   TEL: +81-3-3812-2111 ext. 6902     FAX: +81-3-5800-6969
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: 1996/01/29
Raw View
TABATA Tomohira <loba@k2.t.u-tokyo.ac.jp> writes:

>Can't I use this declaration successfully?

>   class T1 {
>   public:
>      typedef T1 myclass;
>   };

>   class T2 {
>   public:
>      typedef T2 myclass;
>   };

>   class T3 : public T1, T2 {
>   public:
>      typedef T3 myclass;
>   };

That code is strictly conforming (i.e. perfectly legal).

>By gcc-2.7.1 this cannot be compiled because of "request for member
>`myclass' is ambiguous" on the line "typedef T3 myclass;".

This is a bug in gcc.

--
Fergus Henderson              WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au               PGP: finger fjh@128.250.37.3

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]