home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!destroyer!gatech!darwin.sura.net!udel!rochester!rit!cci632!dwr
- From: dwr@cci632.cci.com (Donald W. Rouse II)
- Subject: Re: Proposal for default scope
- Message-ID: <1993Jan8.173654.1189@cci632.cci.com>
- Organization: [Computer Consoles, Inc., Rochester, NY
- References: <mkohtala.726108774@vipunen.hut.fi> <1993Jan8.044714.2027@qualcomm.com>
- Date: Fri, 8 Jan 1993 17:36:54 GMT
- Lines: 29
-
- In article <1993Jan8.044714.2027@qualcomm.com> greg@qualcom.qualcomm.com (Greg Noel) writes:
- [...]
- >The semantics would be that all names defined in the scope would be visible
- >within the scope (subject to the usual scoping/visibility rules, of course);
- >names that were declared in the class description would be the only ones
- >exported from the scope. This would allow a helper function to be defined
- >that had full access to the class private members, but still be type-safe,
- >since the only way to access the helper functions would be from within the
- >scope and the only way to enter the scope would be via the class interface.
- >
- >That is,
- > class Class {
- > public: int func1();
- > };
- > Class:: {
- > int helper() { /* ... */ }
- > int func1() { /* code including calls to helper() */ }
- > }
- >Since helper() is not declared in the class, it is not exported from the
- >scope, while func1() is declared in the class, so it is exported in the
- >normal fashion.
- >
-
- You can accomplish the same thing with
- class Class {
- private: static int helper ();
- public: int func1();
- };
- although you don't get the syntactic sugar.
-