home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / cplus / 2007 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.5 KB  |  40 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!destroyer!gatech!darwin.sura.net!udel!rochester!rit!cci632!dwr
  3. From: dwr@cci632.cci.com (Donald W. Rouse II)
  4. Subject: Re: Proposal for default scope
  5. Message-ID: <1993Jan8.173654.1189@cci632.cci.com>
  6. Organization: [Computer Consoles, Inc., Rochester, NY
  7. References: <mkohtala.726108774@vipunen.hut.fi> <1993Jan8.044714.2027@qualcomm.com>
  8. Date: Fri, 8 Jan 1993 17:36:54 GMT
  9. Lines: 29
  10.  
  11. In article <1993Jan8.044714.2027@qualcomm.com> greg@qualcom.qualcomm.com (Greg Noel) writes:
  12. [...]
  13. >The semantics would be that all names defined in the scope would be visible
  14. >within the scope (subject to the usual scoping/visibility rules, of course);
  15. >names that were declared in the class description would be the only ones
  16. >exported from the scope.  This would allow a helper function to be defined
  17. >that had full access to the class private members, but still be type-safe,
  18. >since the only way to access the helper functions would be from within the
  19. >scope and the only way to enter the scope would be via the class interface.
  20. >
  21. >That is,
  22. >    class Class {
  23. >    public:  int func1();
  24. >    };
  25. >    Class:: {
  26. >        int helper() { /* ... */ }
  27. >        int func1() { /* code including calls to helper() */ }
  28. >    }
  29. >Since helper() is not declared in the class, it is not exported from the
  30. >scope, while func1() is declared in the class, so it is exported in the
  31. >normal fashion.
  32. >
  33.  
  34. You can accomplish the same thing with
  35.     class Class {
  36.     private: static int helper ();
  37.     public:  int func1();
  38.     };
  39. although you don't get the syntactic sugar.
  40.