From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5117b1b6391a0e06 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!nntp.abs.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Fri, 18 Jun 2004 08:32:35 -0400 From: Hyman Rosen User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: A simple ADA puzzle (I haven't the answer) References: <1087410710.477506@master.nyc.kbcfp.com> <1087474761.60413@master.nyc.kbcfp.com> <7o83d0hf6sqgng2980e1tg7iu864m5m50u@4ax.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1087561955.898994@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1087561955 6017 204.253.250.10 Xref: g2news1.google.com comp.lang.ada:1658 Date: 2004-06-18T08:32:35-04:00 List-Id: Dmitry A. Kazakov wrote: > It is not what it appears to be. It is equivalent to > class Local { public: void doit() { printf("Hello World\n"); } }; > void foo () > { > Local Thing; > Thing.doit(); > }; No, that's not correct. Local classes really are local. For example, I could declare two different Local classes in two different functions, and they would not clash. > The following will not compile: > Global * foo () > { > char Text [] = { ... }; > class Local : public Global { > public: void doit() { printf (Text); } // Error Text is unknown! > }; True, but that does not mean that Local isn't local, it simply means that local classes cannot access the automatic variables of their enclosing scopes, for obvious reasons. On the other hand, your code would compile if Text were static char Text[] = "..."; In other words, Loacal is local with respect to its static scope, not its dynamic one, and things that depend on dynamic scope such as parmeters and automatic variables are inaccesible to it.