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

  1. Xref: sparky comp.lang.c++:15952 comp.std.c++:1519
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!taumet!steve
  4. From: steve@taumet.com (Steve Clamage)
  5. Subject: Re: PROPOSAL: Hidden private parts of classes
  6. Message-ID: <1992Nov9.032225.10320@taumet.com>
  7. Organization: TauMetric Corporation
  8. References: <1992Oct30.113234.15010@daimi.aau.dk> <1992Nov7.154137.21910@ucc.su.OZ.AU>
  9. Date: Mon, 9 Nov 1992 03:22:25 GMT
  10. Lines: 33
  11.  
  12. maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  13.  
  14. >    Having hidden data variables causes the compiler some minor
  15. >inconvenience, not knowing the length. However private non-virtual
  16. >member functions cause no problems (if they were allowed). These are
  17. >IMHO needed so as to be able to write small helper members in
  18. >the implementation, I've suggested this be allowed, a suitable 
  19. >syntax does not suggest itself though.
  20.  
  21. If you mean private non-virtual member functions which don't appear in
  22. the class definition, it would cause another language change.
  23. Overloading is resolved before accessibility is checked.  Suppose we have:
  24.  
  25.     class X {
  26.         foo(double);    // private
  27.     public:
  28.         foo(int);
  29.     };
  30.     void bar()
  31.     {
  32.         X x;
  33.         x.foo(2.0);        // which foo() ?
  34.     }
  35.  
  36. This code is in error, since the best match is a private function.  The
  37. semantics would change if "foo(double)" did not have to appear in the
  38. publicly-used class definition; "foo(int)" would be called.  Overloading
  39. is resolved first precisely to avoid quiet semantic changes based only
  40. on access rights.
  41. -- 
  42.  
  43. Steve Clamage, TauMetric Corp, steve@taumet.com
  44. Vice Chair, ANSI C++ Committee, X3J16
  45.