Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!jarthur!uci-ics!rfg From: rfg@ics.uci.edu (Ronald Guilmette) Newsgroups: comp.lang.c++ Subject: Re: Typedef inside of a class definition. Message-ID: <2647C248.28683@paris.ics.uci.edu> Date: 9 May 90 07:10:00 GMT References: <3748@elysium.sw.mcc.com> <26462BED.5865@paris.ics.uci.edu> <1990May9.032300.14501@sjsumcs.sjsu.edu> Reply-To: rfg@ics.uci.edu (Ronald Guilmette) Organization: UC Irvine Department of ICS Lines: 44 In article <1990May9.032300.14501@sjsumcs.sjsu.edu> horstman@sjsumcs.SJSU.EDU (Cay Horstmann) writes: >In article <26462BED.5865@paris.ics.uci.edu> rfg@ics.uci.edu (Ronald Guilmette) writes: >> >>I really should let Michael answer this one but... >> >>The C++ language rules have changed recently with respect to the scope >>of things declared within classes/structs/unions. >> >>It used to be that if you defined a type (via a typedef statement, or via >>a struct, class, union, or enum type definition) within a class, that the >>scope of the new typename was made "global". >> >>Nowadays, the scopes of such names are (or will soon be) restricted to >>the class itself (and its member functions of course). >> >Fascinating feature... Does that mean that one can have private, protected >and public typedefs, all of which live in the name space of the class, with >type scope resolution operators when a public type is used outside member >functions, like this? > >class X >{ >public: >typedef ... T; > >... > >}; > >X::T a; NO. One *cannot* (as of now anyway). I have it on good authority however that all such things ought to be allowed at some (unspecified) point in the future. At that time, nested types will become like other categories of members (i.e. data members, function members, and enumeral members) and access-specifiers will apply. Scope resolution via :: will operate for type members just like for other categories of members. // Ron Guilmette (rfg@ics.uci.edu) // C++ Entomologist // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.