🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1480

Re: Defining members of class T within cla

#1480
From: Henry Baker
Date: Mon, 07 Aug 1995 07:50
59 lines
2640 bytes
In article <401l3v$eri@engnews2.Eng.Sun.COM>, clamage@Eng.Sun.COM (Steve
Clamage) wrote:

> hbaker@netcom.com (Henry Baker) writes:
> 
> >So, since the structure I was defining did not 'contain' a member of the
> >class being defined,

In fact, ARM 9.7:

"Note that simply declaring a class nested in another does _not_ mean
that the enclosing class _contains_ an object of the enclosed class.
Nesting expresses scoping, _not containment_ of sub-objects."  [Emphasis
supplied.]

> Yes it did. The inner struct had a member of an incomplete type.
> 
> >class pair
> >{class pair_rep {pair car,cdr;};
> > pair_rep *rep;};                // Only needs to know sizeof(pointer).
> 
> Class pair_rep has members of type pair, but type pair is not a
> complete type at that point in the source code. The problem is not
> the pointer to pair_rep, but the definition of pair_rep itself.
> 
> Another example, without any cross-referencing:
> 
> class A;
> 
> class B {
>     A a; // invalid, since A is not a complete type
> };
> 
> 
> It doesn't matter whether you use class B or not. Its definition
> is invalid. The definition of class B must appear after that of
> class A, or be removed entirely. In your example, you have to define
> the nested class pair_rep after the definition of pair, not inside it.

But what about the ANSI/ISO resolution, 9.7, page 421:

"Like a member function, a nested class may be declared within the
enclosing class and defined elsewhere in the same or containing scope,
using the qualified name for the class definition:..."

[Example showing what I would call 'rewriting' semantics for nested classes.]

One might reasonably infer that 'like a member function' implied that the same
sort of 'rewriting equivalence' exists for nested classes as well as member
function bodies.

Since this is an entirely satisfactory interpretation, which eliminates
the necessity of many unpleasant explicit rewritings, I would argue that
the ANSI/ISO standard adopt this reading of these passages regarding
nested class declarations.

-- 
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html
Technical Details
Message-ID: <hbaker-0608952350520001@192.0.2.1>
Path: arc1-ca.pugleaf.net!netcom.com!NewsWatcher!user
References: <3vrcu8$pci@galaxy.ucr.edu> <3vthqo$m5t@engnews2.Eng.Sun.COM> <hbaker-0508951007050001@192.0.2.1> <401l3v$eri@engnews2.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++,comp.lang.c++
Path: arc1-ca.pugleaf.net!netcom.com!NewsWatcher!user
From: hbaker@netcom.com (Henry Baker)
Subject: Re: Defining members of class T within cla
Message-ID: <hbaker-0608952350520001@192.0.2.1>
Sender: hbaker@netcom3.netcom.com
Organization: nil organization
References: <3vrcu8$pci@galaxy.ucr.edu> <3vthqo$m5t@engnews2.Eng.Sun.COM> <hbaker-0508951007050001@192.0.2.1> <401l3v$eri@engnews2.Eng.Sun.COM>
Date: Mon, 7 Aug 1995 07:50:52 GMT