From 8810396260578130784
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,5e0145d162a6d1d6
X-Google-Attributes: gidf78e5,public
From: Srinivas Vobilisetti <srv@cs.wayne.edu>
Subject: Re: Why is granting friendship to a templ. parameter ill-formed?
Date: 1998/03/10
Message-ID: <350587D6.3EA6@cs.wayne.edu>#1/1
X-Deja-AN: 332692451
Content-Transfer-Encoding: 7bit
References: <6dop9s$kq6$1@news.utu.fi> <35005B2A.7410@cs.wayne.edu> <1yiuppeaon.fsf@dshp01.ntc.nokia.com> <6e2i9u$rig$1@news.interlog.com>
X-Original-Date: Tue, 10 Mar 1998 11:35:02 -0700
X-Authentication-Warning: crchh14.us.nortel.com: news set sender to  srv@cs.wayne.edu using -f
Content-Type: text/plain; charset=us-ascii
Organization: Bell Northern Research
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANQWG2OEDnX0m9pzZAQGG3wGAlw1GZkAtnrIa8Tmk2KEvT0MqlAOMpe/J q+JWPKGo1hIVSRKwiIP0Wu6IFXdflcT3 =iCgQ
Mime-Version: 1.0
Newsgroups: comp.std.c++


Daniel Parker wrote:
> 
> Marc Girod wrote in message <1yiuppeaon.fsf@dshp01.ntc.nokia.com>...
> >>>>>> "SV" == Srinivas Vobilisetti <srv@cs.wayne.edu> writes:
> >
> >SV> To prevent back door access to template class's private members. If you
> >SV> give friendship based on the template parameter, then any class can get
> >SV> access to the template private members thru back door
> >
> >"Back door"??? What is the front door then? 

Front door? List all the classes as friends in the template class
definition.

ARM in section 11.4 says, "Friendship, like all other access, is granted
by the class - not unilaterally grabbed by the friend".

ARM also says (about overloaded functions), "One could imagine declaring
all functions called f friends by a single declaration, but doing so
would be a bit indiscriminate. It would enable a user to grab access to
a class simply by declaring a function f with a hitherto unused argument
type."

> >This would only be
> >clear and explicit. It could be the only access. I know I lack it
> >badly, and where I do, I have to make the access public and put
> >dynamic guards: a shame!

Granting friendship access to a template parameter violates
encapsulation. Probably, you need to change your design.

> I agree wholeheartedly with this post; the justification stated above is,
> quite frankly, nuts.  

What is nuts in it? 

>What it means is that the developer is compelled to
> make a data member public that he'd rather not, which is bad.  

No. what it means is that the developer should rethink about his design.

>If the intent
> of the standard was to prevent the client from discovering a way of misusing
> a class, I have some very bad news:  in C++ it is always possible for the
> client to misue a class.  That's a non-issue, utterly beside the point.

The intent of of the standard was to prevent accidental misuse of a
class but not intentional misuse.

> 
> Regards,
> Daniel Parker
> 

Regards,
Srinivas
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



