Article View: comp.std.c++
Article #1465Defining members of class T within class T (_not_ recursive!)
From: Henry Baker
Date: Sat, 29 Jul 1995 23:47
Date: Sat, 29 Jul 1995 23:47
36 lines
1585 bytes
1585 bytes
Path: holonet!colossus.holonet.net!news.sprintlink.net!gatech!news.uoregon.
edu!news.bc.net!info.ucla.edu!library.ucla.edu!csulb.edu!csus.edu!
netcom.com!NewsWatcher!user
From: hbaker@netcom.com (Henry Baker)
Subject: Defining members of class T within class T (_not_ recursive!)
Message-ID: <hbaker-2907951547200001@192.0.2.1>
Sender: hbaker@netcom9.netcom.com
Organization: nil
Date: Sat, 29 Jul 1995 23:47:20 GMT
Suppose I have the following nested class:
struct pair
{struct pair_rep
{pair car,cdr;}; // inner class has member of outer class.
pair_rep *rep;};
I understand the rule saying that a class cannot be a member of itself
[Stroustrup#2, page 545] (Bertrand Russell is now spinning in his grave ;-),
but I'm having trouble understanding why a _nested_ class cannot have a
member
of the outer class being defined. This is especially irritating, since the
above is capable of being rewritten as [Stroustrup#2, page 645]:
struct pair
{struct pair_rep;
pair_rep *rep;};
struct pair::pair_rep
{pair car,cdr;};
Are compiler writers just being lazy, or what??
--
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html
Technical Details
Message-ID:
<950729200137682@wem.org>Path:
arc1-ca.pugleaf.net!colossus.holonet.net!christ!henry.bakerShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!colossus.holonet.net!christ!henry.baker From: henry.baker@wem.org (Henry Baker) Newsgroups: comp.std.c++,comp.lang.c++ Subject: Defining members of class T within class T (_not_ recursive!) Date: Sat, 29 Jul 1995 23:47:20 GMT Message-ID: <950729200137682@wem.org> Organization: World Evangelist Ministry (310) 398-7804 Distribution: world Sender: hbaker@netcom9.netcom.com