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