home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13305 < prev    next >
Encoding:
Text File  |  1992-09-04  |  1.2 KB  |  60 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!panther!mothost!motsrd!news
  3. From: shang@corp.mot.com (David (Lujun) Shang)
  4. Subject: Re: What does "::" really mean?
  5. Message-ID: <1992Sep4.141030.9527@cadsun.corp.mot.com>
  6. Sender: news@cadsun.corp.mot.com
  7. Reply-To: shang@corp.mot.com
  8. Organization: Motorola, Inc., Software Research and Development, Rolling Meadows, IL. 60008
  9. Date: Fri, 4 Sep 92 14:10:30 GMT
  10. Lines: 48
  11.  
  12.  
  13. I'd like to add something to my last post on this subject.
  14.  
  15. Consider an example:
  16.  
  17. class AA
  18. { public:
  19.     class NAA {};
  20. };
  21.  
  22. class AA1: public AA
  23. { public:
  24.     class AA
  25.     {  public:
  26.          class NAA{};
  27.     };
  28. };
  29.  
  30. class AA2: public AA
  31. { public:
  32.     class AA
  33.     {  public:
  34.          class NAA{};
  35.     };
  36. };
  37.  
  38. class BB: public AA1, public AA2
  39. {
  40.    AA1::AA::NAA  x;     // what is the type of x???
  41. };
  42.  
  43. What is the type of member "x" in class BB?
  44.  
  45. We should use:
  46.  
  47.    AA1.AA.NAA
  48.  
  49. to denote the class NAA nested in class AA nested in class AA1, and use
  50.  
  51.    AA1::AA.NAA
  52.  
  53. to denote the class NAA nested in the base class AA of AA1.
  54.  
  55. To conclude, we use"::" to denote a specific base when the member is ambiguous  
  56. due to multiple inheritace, and we use "." to denote the member or property of  
  57. a qualifying entity ( an object or a class ).
  58.  
  59. David Shang
  60.