brucec@phoebus.phoebus.labs.tek.com (Bruce Cohen;;50-662;LP=A;) (08/21/90)
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
jimad@microsoft.UUCP (Jim ADCOCK) (08/23/90)
E&S calls out nested name spaces, and there seems to be wide agreement that that is the way to go, so you can hope to see it in future compilers. I would not expect to see this feature in compilers that are claiming less than "2.1" compatibility, however.