home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15883 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.3 KB  |  53 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!stanford.edu!rock!concert!duke!jep
  2. From: jep@cs.duke.edu (Jonathan E. Polito)
  3. Newsgroups: comp.lang.c++
  4. Subject: Class scope and class declarations
  5. Message-ID: <JEP.92Nov6155424@thneed.cs.duke.edu>
  6. Date: 6 Nov 92 20:54:24 GMT
  7. Sender: news@duke.cs.duke.edu
  8. Distribution: comp
  9. Organization: Duke University CS Dept., Durham, NC
  10. Lines: 40
  11. Nntp-Posting-Host: thneed.cs.duke.edu
  12.  
  13.  
  14. Hello,
  15.     I have a question that seems somewhat open to interpretation.
  16. I have not been able to find a specific reference in the ARM, nor in
  17. Lippman's C++ Primer.
  18.  
  19. It is clear that:
  20. class X;
  21.  
  22. class Y {
  23. public:
  24.     Y();
  25. private:
  26.     class X* xptr;
  27. };
  28.  
  29. class X {
  30. public:
  31.     int info;
  32. };
  33.  
  34. Y::Y() {
  35.     X tmp;
  36.     tmp.info = 1;
  37. }
  38.  
  39. will cause tmp to be defined as a class X (at file scope) object. What
  40. if the first class X; forward declaration is deleted though? Is the
  41. effect then that xptr in class Y is a pointer to a local class X that
  42. is never defined? This is one interpretation though I have seen a
  43. number of programs that rely on class X* to be a forward declaration
  44. to a class defined later at file scope.
  45.  
  46. Thanks in advance,
  47.  
  48. Jon.
  49. --
  50. Jonathan Polito                                      DoD #x (K 100)
  51. jep@cs.duke.edu                                  jpolito@encore.com 
  52.               "You Don't Say...." --- Sylvia Plath
  53.