Thread View: comp.std.c++
2 messages
2 total messages
Started by Desmond Dsouza
Sat, 05 Jan 1991 02:13
Nested Class Definitions Question
Author: Desmond Dsouza
Date: Sat, 05 Jan 1991 02:13
Date: Sat, 05 Jan 1991 02:13
36 lines
1515 bytes
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
DISCONTINUING comp.std.c++ (was: Nested Class Definitions Question)
Author: Ron Guilmette
Date: Sun, 20 Jan 1991 10:20
Date: Sun, 20 Jan 1991 10:20
29 lines
1557 bytes
1557 bytes
In article <DSOUZA.91Jan4201341@optima.cad.mcc.com> dsouza@optima.cad.mcc.com (Desmond Dsouza) writes:
+
+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 { ... };
I have now seen numerous messages posted to this newsgroup which did not
belong here, however I have yet to see any response whatsoever to this
very valid question about a significant C++ standards issue.
What's the problem? Is there really such a total disinterest in C++
standards issues by readers of usenet news? Should this newsgroup
be disbanded due to lack of interest?
--
// Ron Guilmette - C++ Entomologist
// Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg
// Motto: If it sticks, force it. If it breaks, it needed replacing anyway.
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