Path: 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: Date: 5 Jan 91 02:13:41 GMT Sender: news@cadillac.CAD.MCC.COM Distribution: na Organization: MCC CAD Program, Austin, Texas Lines: 36 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