Archived

This topic is now archived and is closed to further replies.

vbisme

Restricted friend

Recommended Posts

vbisme    100
When a class declares another class as "friend" the other class could access all of it''s private and protected members. Is there a way to allow the other class to access only certain members not all of it?

Share this post


Link to post
Share on other sites
Kylotan    10010
I can''t think of any way that it''s possible, without playing some sort of inheritance trick. I doubt that it''s worth the effort. When you declare another class as a friend, that implies that the 2 classes go naturally together... which in turn implies that you have control over both classes, so encapsulation from each other is less important than encapsulation of the 2 classes from others. So my opinion is that it''s not generally worth worrying about.

Share this post


Link to post
Share on other sites