Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!claris!hearn From: hearn@claris.com (Bob Hearn) Newsgroups: comp.lang.c++ Subject: Re: Are Class Decl.'s Legal in Funcs ? Message-ID: <9418@claris.com> Date: 4 Apr 89 00:31:50 GMT References: <890403-150348-4532@Xerox> Organization: Claris Corporation, Mountain View CA Lines: 27 From article <890403-150348-4532@Xerox>, by SJohnson.ElSegundo@XEROX.COM: > Is the following code legal ? Since C/C++ doesn't allow lexical nesting of > functions, I'd be inclined to believe that having My_Class::doit() inside > func would be a no-no. > > As it turns out, Oregon Software's occ will compile and run the example > below, while Gnu's g++ (version 1.32.0) goes into some kind of infinite > loop during compilation. > > > Swen Johnson > SJohnson.ElSegundo@Xerox.COM > > ------------------------------------------------------------------------- > #include > > void func() { > class My_Class { [etc.] I don't know about classes nested in functions, but classes nested in classes are legal - except they don't mean what you think they do. Their scope is global. This is VERY ANNOYING. The one thing I hate most about C is lack of nested scoping. Bob Hearn hearn@claris.com