home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!nuscc!solomon.technet.sg!arthur
- From: arthur@solomon.technet.sg (Arthur Sombrito)
- Newsgroups: comp.lang.c++
- Subject: Re: scope of typedef declaration within a class declaration?
- Message-ID: <1992Jul21.105613.14776@nuscc.nus.sg>
- Date: 21 Jul 92 10:56:13 GMT
- References: <130538@lll-winken.LLNL.GOV>
- Sender: usenet@nuscc.nus.sg
- Organization: National University of Singapore
- Lines: 44
-
- casey@gauss.llnl.gov (Casey Leedom) writes:
- :
- : I'm working with SGI's C++ 2.1.1 which is based on AT&T's cfront 2.0.
- : SGI's C++ promotes typedef declarations within class declarations to the
- : global scope. Moreover, it doesn't even let me access the typedef name
- : via class-name::typedef-name. This seems to be contrary to the C++ 2.0
- : specification. Section 10.4, Summary of Scope Rules, in the AT&T C++
- : Language System manual even specifies:
- :
- : ``... These rules apply uniformly for all names (including
- : typedef-names (sec.7.1.3) and class-names (sec.9.1)) wherever
- : the grammar allows such names in the context discussed by a
- : particular rule. ...''
- :
- : Here's an example of what I'm trying to do:
- :
- : 1 class foo {
- : 2 public:
- : 3 typedef int bar;
- : 4 bar x;
- : 5 };
- : 6
- : 7 main()
- : 8 {
- : 9 foo::bar i;
- : 10 foo f;
- : 11
- : 12 i = 1;
- : 13 f.x = i;
- : 14 }
- :
- : SGI's C++ compiler complains about line 9 (getting confused about missing
- : semicolons, etc.) and the only way I can make it work is if I change line
- : 9 to read ``bar i;''
- :
- : Am I completely misconstruing the meaning of the scoping rules with
- : regard to typedefs???
- :
- : Casey
-
- You got it right. It's just one of the specifications that cfront does not
- adhere to.
-
- Art
-