home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:15916 comp.std.c++:1511
- Newsgroups: comp.lang.c++,comp.std.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: PROPOSAL: Hidden private parts of classes
- Message-ID: <1992Nov7.154137.21910@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Oct30.113234.15010@daimi.aau.dk>
- Date: Sat, 7 Nov 1992 15:41:37 GMT
- Lines: 39
-
- In article <1992Oct30.113234.15010@daimi.aau.dk> sabroe@daimi.aau.dk (Morten Sabroe Mortensen) writes:
- > Lately I've coded a lot of small libraries in C++, and been
- >thinking, why it's not possible to hide private parts, -it doesn't
- >seem to be possible!
-
-
- You will note that 'private' means inaccessible to the public,
- not invisible. It was explicitly defined that way in the ARM.
-
- 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.
-
- Having an explict 'hidden' keyword could also be done:
-
- class A { ..
- hidden: int x;
- };
-
- where x is not just inaccessible but invisible. (But not to the programmer)
-
- However there IS a way to separate the implementation and
- the interface, namely to use an abstract class for the interface
-
- class X { public: f(); };
- class Y : public X { public: f(); private: int x;};
-
- This makes x truly invisible to users of X objects, but not those
- that must construct them. Note that this scheme will fail
- if downcasting is allowed :-)
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-