From 2480201842003709227
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,64c04ae5e5b49e61
X-Google-Attributes: gidf78e5,public
From: comeau@panix.com (Greg Comeau)
Subject: Re: class-definition using a qualified-name
Date: 2000/04/21
Message-ID: <8dlo52$5i0$1@panix.com>#1/1
X-Deja-AN: 613603662
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <38FD77E7.F3F90217@cc.u-szeged.hu>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 956242110 mail2news:17439 mail2news mail2news.demon.co.uk
Organization: Comeau Computing; http://www.comeaucomputing.com
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Reply-To: comeau@comeaucomputing.com
Newsgroups: comp.std.c++
X-Newsposter: trn 4.0-test55 (26 Feb 97)

In article <38FD77E7.F3F90217@cc.u-szeged.hu> Beszedes Arpad <beszedes@cc.u-szeged.hu> writes:
>I cannot find anywhere in the standard if the following is legal or not:
>class outer
>{
>public:
>  class inner;
>};
>
>class other_class
>{
>  class outer::inner
>  {
>  public:
>    int i;
>  };
>  // ...
>};
>....
>I.e. can be a class defined outside of its "real" container scope
>(namely in an another namespace- or class-scope)?

Namespace yes, its class yes, other class no.

>(Btw my compiler -- MSVC6 -- compiles the above code).

Comeau C++ gives:
line 9: error: class "outer::inner" cannot be defined in the current scope
    class outer::inner
          ^

which is backed up by 9.7p3: "If class X is defined in a namespace scope,
a nested class Y may be declared in class X and later defined in the
definition of class X or be later defined in a namespace scope enclosing
the definition of class X." Since other_class is not a namespace
scope or within outer, then defining outer::inner in other_class
is an error.

- Greg
-- 
Comeau Computing, Producers of Comeau C/C++ 4.2.42 (4.2.43 BETA starting)
Try Comeau C++ online at http://www.comeaucomputing.com/tryitout
Email: comeau@comeaucomputing.com / WEB: http://www.comeaucomputing.com

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




