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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!gatech!rpi!utcsri!helios.physics.utoronto.ca!alchemy.chem.utoronto.ca!plumbum.chem.utoronto.ca!mbersohn
  3. From: mbersohn@alchemy.chem.utoronto.ca (M. Bersohn)
  4. Subject: A KIND OF RESTRICTED ACCESS TO MEMBER FUNCTIONS
  5. Message-ID: <1993Jan12.100913.5014@alchemy.chem.utoronto.ca>
  6. Originator: mbersohn@plumbum.chem.utoronto.ca
  7. Sender: news@alchemy.chem.utoronto.ca (USENET news)
  8. Organization: University of Toronto Chemistry Department
  9. Date: Tue, 12 Jan 1993 10:09:13 GMT
  10. Lines: 21
  11.  
  12. <I would like to have a class that has some public methods that can
  13. <only be used by a certain group of classes.
  14. <Lets call this class A, and I want B,C,D &E to be able to use the
  15. <public methods on A. (no problem so far)
  16. <However, I don't want classes X, Y, &Z to be able to use the methods,
  17. <nor any other similar classes added in the future.
  18. <I don't want B,C,D &E to access the private data of A, so I can't make
  19. <them friend classes.  A,B,C,D, &E aren't in the same heirarchy, so I
  20. <can't use inheritance to have a solution to the problem.
  21. <What I would like to be able to do is say that the public methods of A
  22. <are only public to a certain group of classes, and private to all
  23. <others.
  24. <Any ideas?
  25.  
  26. <post, or reply to ralph@dci.pinetree.org
  27. How about giving your public methods in A an extra
  28. argument? This argument would identify the calling class.
  29. At the beginning of the member functions in A you will
  30. check the identifier and if it does not correspond to
  31. classes B,C,D, or E you will exit or exception-handle or
  32. whatever.
  33.