Xref: utzoo comp.lang.c++:9082 comp.std.c++:205 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!zephyr.ens.tek.com!tekcrl!brucec From: brucec@phoebus.phoebus.labs.tek.com (Bruce Cohen;;50-662;LP=A;) Newsgroups: comp.lang.c++,comp.std.c++ Subject: Locality of structure tag names Message-ID: Date: 20 Aug 90 21:47:02 GMT Sender: news@tekcrl.LABS.TEK.COM Followup-To: comp.lang.c++ Organization: Tektronix Inc. Lines: 48 I'd like to get a clarification of the locality of scope of a structure tag name declared inside a class. According to Ellis&Stroustrup, a typename declared in a class declaration is local to that class, and (modulo C compatibility issues) all types, including structure tags, share a namespace. My reading of this is that structure tags declared inside a class definition are local to the class (and that's the way I'd like it to be). Am I assuming too much? My Cfront 2.0 makes class-nested typedefs and structure tags global (at file scope, that is), which is about what I expected. Example: class Nest { public: Nest(int); private: struct nested { int egg; }; typedef struct nested nestedType; }; Nest::Nest(int i) { struct nested* nesting = new struct nested [i]; // within scope } void Tree(struct nested* nesting) // illegal: out of scope { // mumble ... } void Shrub(nestedType* nesting) // illegal: out of scope { // mumble ... } -- --------------------------------------------------------------------------- NOTE: USE THIS ADDRESS TO REPLY, REPLY-TO IN HEADER MAY BE BROKEN! Bruce Cohen, Computer Research Lab email: brucec@tekcrl.labs.tek.com Tektronix Laboratories, Tektronix, Inc. phone: (503)627-5241 M/S 50-662, P.O. Box 500, Beaverton, OR 97077