🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Nested Class Definitions Question

#779
From: Desmond Dsouza
Date: Sat, 05 Jan 1991 02:13
36 lines
1515 bytes
Is it legal to forward declare a class nested in another class?
I believe the following is illegal in C++? If so, why? It is a
useful form of modularity.

class PRINTING_SYS {
  class PRINTER;      // Nested class forward declaration
  class PRINT_QUEUE;  //  "  
public:
  spool();
};

class PRINTING_SYS::PRINTER { ... };
class PRINTING_SYS::PRINT_QUEUE { ... };

According to the ARM:
p. 164
"Except for historical reasons, a class declaration would have been called
a class definition"
i.e. class A {...}; is called a class declaration.

p. 185: "A class may be declared within another class"

p. 187: "Member functions and static data members of a nested class
can be defined in the global scope"

Putting these 3 together it seems that nested class (forward)
declarations are not legal.

---
Desmond.
--

-------------------------------------------------------------------------------
 Desmond D'Souza, MCC CAD Program | ARPA: dsouza@mcc.com | Phone: [512] 338-3324
 Box 200195, Austin, TX 78720 | UUCP: {uunet,harvard,gatech,pyramid}!cs.utexas.edu!milano!cadillac!dsouza
Technical Details
Message-ID: <DSOUZA.91Jan4201341@optima.cad.mcc.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!milano!cadillac!dsouza

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!milano!cadillac!dsouza
From: dsouza@optima.cad.mcc.com (Desmond Dsouza)
Newsgroups: comp.std.c++
Subject: Nested Class Definitions Question
Message-ID: <DSOUZA.91Jan4201341@optima.cad.mcc.com>
Date: 5 Jan 91 02:13:41 GMT
Sender: news@cadillac.CAD.MCC.COM
Distribution: na
Organization: MCC CAD Program, Austin, Texas
Lines: 36