Thread View: comp.std.c++
3 messages
3 total messages
Started by Gregory Bond
Thu, 14 Dec 1995 04:52
Scope of fwd declaratoins of nested classes
Author: Gregory Bond
Date: Thu, 14 Dec 1995 04:52
Date: Thu, 14 Dec 1995 04:52
26 lines
1525 bytes
1525 bytes
Try this for a corner case:
class A {
public:
class B;
private:
class B {
public:
int b;
};
};
// Is A::B visible here? Or is the above declaration ill-formed?
// I.e. is the scope of A::B established when it is declared or when
// it is defined? or should the two scopes be the same?
// FWIW, g++ 2.7.1 thinks this is well-formed and A::B is visible.
--
Gregory Bond <gnb@bby.com.au> Burdett Buckeridge & Young Ltd Melbourne Australia
``Efforts to maintain the "purity" of a language only succeed in establishing an
elite class of people who know the shibboleths. Ordinary folks know better,
even if they don't know what "shibboleth" means.'' - Larry Wall
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Scope of fwd declaratoins of nested classe
Author: Steve Clamage
Date: Thu, 14 Dec 1995 16:59
Date: Thu, 14 Dec 1995 16:59
28 lines
1398 bytes
1398 bytes
In article 95Dec14120500@dame.bby.com.au, gnb@bby.com.au (Gregory Bond) writes:
>
>class A {
> public:
> class B;
> private:
> class B {
> public:
> int b;
> };
>};
>
>// Is A::B visible here? Or is the above declaration ill-formed?
From the September draft, 11.1 "Access specifiers", paragraph 3:
"When a member is redeclared within its class definition, the access
specified at its redeclaration shall be the same as at its initial
declaration."
An example just like yours appears in the draft to illustrate the error.
---
Steve Clamage, stephen.clamage@eng.sun.com
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Scope of fwd declaratoins of nested classe
Author: Ulf Schuenemann
Date: Thu, 21 Dec 1995 20:05
Date: Thu, 21 Dec 1995 20:05
46 lines
1700 bytes
1700 bytes
In article <4apjod$7tp@engnews1.eng.sun.com>, clamage@Eng.Sun.Com (Steve Clamage) writes:
|> In article 95Dec14120500@dame.bby.com.au, gnb@bby.com.au (Gregory Bond) writes:
|> >
|> >class A {
|> > public:
|> > class B;
|> > private:
|> > class B {
|> > public:
|> > int b;
|> > };
|> >};
|>
|> An example just like yours appears in the draft to illustrate the error.
The only way I see to hide the definition of a public nested class
is to put it into a different translation unit.
// public header
class A {
public:
class B;
};
// implementation file for class A
class A::B {
public:
int b;
};
Ulf Schuenemann
--------------------------------------------------------------------
,_. Ulf Schuenemann
#, \ Fakultaet fuer Informatik, Technische Universitaet Muenchen, Germany.
| > email: schuenem@informatik.tu-muenchen.de
v=-< WWW: http://hphalle2.informatik.tu-muenchen.de/~schuenem/
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads