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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!ukma!darwin.sura.net!sgiblab!ampex!leepeng
  3. From: leepeng@ampex.com (Peng Lee)
  4. Subject: Re: Multiple Header Files Problem
  5. Message-ID: <1992Nov6.172422.2563@ampex.com>
  6. Sender: usenet@ampex.com (News Poster)
  7. Nntp-Posting-Host: dd2-s4-12
  8. Organization: Ampex Corporation, Redwood City CA
  9. References: <1992Nov3.113121.3388@ntuix.ntu.ac.sg> <BxAA12.2Cz@well.sf.ca.us>
  10. Date: Fri, 6 Nov 1992 17:24:22 GMT
  11. Lines: 29
  12.  
  13. In article <BxAA12.2Cz@well.sf.ca.us> donovan@well.sf.ca.us (Sean Donovan) writes:
  14. >In article <1992Nov3.113121.3388@ntuix.ntu.ac.sg> gthkoh@ntuix.ntu.ac.sg (Koh Thong Hwee) writes:
  15. >
  16. >> [define class B which references class A which references class B]
  17. >
  18. >In C++ you can specify a forward reference to a class by just saying:
  19. >
  20. >class <class-name>;
  21. >
  22. >In that header module you can then declare a member variable to that class.
  23. >
  24. >Ex:
  25. >
  26. >class A;
  27. >
  28. >class B {
  29. >private:
  30. >   class A *foo;
  31. >};
  32. >
  33. >then go on to define your cyclic relation:
  34. >
  35. >class A {
  36. >private:
  37. >    class B *bar;
  38. >};
  39.  
  40.  I wonder if this is how god solve the Chicken and Egg problem when
  41.  (s)he created the world :-).
  42.