home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:15952 comp.std.c++:1519
- Newsgroups: comp.lang.c++,comp.std.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: PROPOSAL: Hidden private parts of classes
- Message-ID: <1992Nov9.032225.10320@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Oct30.113234.15010@daimi.aau.dk> <1992Nov7.154137.21910@ucc.su.OZ.AU>
- Date: Mon, 9 Nov 1992 03:22:25 GMT
- Lines: 33
-
- maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
-
- > Having hidden data variables causes the compiler some minor
- >inconvenience, not knowing the length. However private non-virtual
- >member functions cause no problems (if they were allowed). These are
- >IMHO needed so as to be able to write small helper members in
- >the implementation, I've suggested this be allowed, a suitable
- >syntax does not suggest itself though.
-
- If you mean private non-virtual member functions which don't appear in
- the class definition, it would cause another language change.
- Overloading is resolved before accessibility is checked. Suppose we have:
-
- class X {
- foo(double); // private
- public:
- foo(int);
- };
- void bar()
- {
- X x;
- x.foo(2.0); // which foo() ?
- }
-
- This code is in error, since the best match is a private function. The
- semantics would change if "foo(double)" did not have to appear in the
- publicly-used class definition; "foo(int)" would be called. Overloading
- is resolved first precisely to avoid quiet semantic changes based only
- on access rights.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-