Article View: comp.std.c++
Article #3326Anyone considered inheritable friendship?
From: Eugene Radchenko
Date: Mon, 12 Feb 1996 16:20
Date: Mon, 12 Feb 1996 16:20
51 lines
2694 bytes
2694 bytes
Hi people!
Has anyone proposed/considered the inheritable friendship in addition to
the current one? Suppose the following design (non-template version for
brevity):
class Actor { //performs some actions
public:
//define type X here
class LittleAction { //performs some elementary action on X
public:
virtual void DoIt(X *x);
virtual ~LittleAction();
};
protected:
LittleAction *doer;
Actor(LittleAction *the_doer);
void Perform(vector<X> &vec);
friend class LittleAction;
//some protected data - e.g. some cached procesed 'vec' - needed by
// LittleAction
};
Here LittleAction defines abstract interface. We can implement it
differently and pass derived classes to Actor constructor. Actor and
LittleAction hierarchies must work together, LittleAction accessing some
private Actor data (which should not be accessed by other classes).
Everything is OK unless we really use OO design and derive something from
LittleAction - and oops! private data is inaccessible.
I think we should allow inheritable friendship (probably in addition to
current non-inheritable one). Anyway, we are not creating the Pentagon
security system and thus should not be much afraid of deriving Spy from
TrustedUser. Especially considering that otherwise all ends in making this
data public (that's the problem with totalitarism - too tight a regime gets
overthrown).
Bye-Bye Genie
--
-----------------------------------------------------------------------
Eugene V. Radchenko Research associate, Computer Chemistry
E-mail: eugene@qsar.chem.msu.su Fax: +7-(095)939-0290
Ordinary mail: Chair of Organic Chemistry, Department of Chemistry,
Moscow State University, 119899 Moscow, Russia
## The careful application of terror is also a form of communication ##
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is
summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
]
Technical Details
Message-ID:
<AFVop7nqs7@qsar.chem.msu.su>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: "Eugene Radchenko" <eugene@qsar.chem.msu.su> Newsgroups: comp.std.c++ Subject: Anyone considered inheritable friendship? Date: 12 Feb 1996 16:20:53 GMT Organization: Lab. of Org.Synth., MSU Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <AFVop7nqs7@qsar.chem.msu.su> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Mailer: dMail [Demos Mail for DOS v1.23] Content-Length: 1909 X-Lines: 46 Originator: clamage@taumet