home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / cplus / 1130 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.3 KB  |  62 lines

  1. Newsgroups: comp.std.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.140615.9469@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. References: <1992Sep4.001405.4117@cadsun.corp.mot.com>
  10. Date: Fri, 4 Sep 92 14:06:15 GMT
  11. Lines: 49
  12.  
  13.  
  14. I'd like to add something to my last post on this subject.
  15.  
  16. Consider an example:
  17.  
  18. class AA
  19. { public:
  20.     class NAA {};
  21. };
  22.  
  23. class AA1: public AA
  24. { public:
  25.     class AA
  26.     {  public:
  27.          class NAA{};
  28.     };
  29. };
  30.  
  31. class AA2: public AA
  32. { public:
  33.     class AA
  34.     {  public:
  35.          class NAA{};
  36.     };
  37. };
  38.  
  39. class BB: public AA1, public AA2
  40. {
  41.    AA1::AA::NAA  x;     // what is the type of x???
  42. };
  43.  
  44. What is the type of member "x" in class BB?
  45.  
  46. We should use:
  47.  
  48.    AA1.AA.NAA
  49.  
  50. to denote the class NAA nested in class AA nested in class AA1, and use
  51.  
  52.    AA1::AA.NAA
  53.  
  54. to denote the class NAA nested in the base class AA of AA1.
  55.  
  56. To conclude, we use"::" to denote a specific base when the member is ambiguous  
  57. due to multiple inheritace, and we use "." to denote the member or property of  
  58. a qualifying entity ( an object or a class ).
  59.  
  60. David Shang
  61.  
  62.