[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: accessing protected members of a parent class
From:       Roberto Alsina <ralsina () kde ! org>
Date:       2002-04-04 18:20:36
[Download RAW message or body]

On Thu, 4 Apr 2002, Lubos Lunak wrote:

> On Thu 4. April 2002 19:56, Roberto Alsina wrote:
> > On Thu, 4 Apr 2002, Ellis Whitehead wrote:
> > > On Thursday 04 April 2002 11:40, Patrick Julien wrote:
> > > > you have to make B a friend in the protected or private section of
> > > > class A.
> > >
> > > That is in fact what I've been doing to get around the problem.  But its
> > > ugliness quotient is horrendous and you can only use this approach for
> > > sub-classes which you program yourself -- leaving the option unavailable
> > > to programmers using the library...
> >
> > Ok, the real answer is: "you are not supposed to access protected members
> > of the parent class".
> >
> > If the guy that designed the class wanted you to access that member, he
> > would have made the member public.
> 
>  You should probably tell the ANSI/ISO C++ guys that they have one 
> superfluous keyword in C++. Otherwise, if 'you are not supposed to access 
> protected members of the parent class', why should there be a keyword that 
> lets one access protected members of the parent class?

You missed the "you" ;-)

You, person using class X in your app, are not supposed to access
protected members of it. 

However, (another) you, person who is developing a set of classes that
includes class X, are probably supposed to access protected members of it.

That is why the second "you" can fix the parent class to make the child
class a friend of it, and the first "you" can not.

On the other hand, I agree that protected is pretty useless, but I doubt
the ISO guys will care about my opinion ;-)

 ("\''/").__..-''"`-. .         Roberto Alsina
 `9_ 9  )   `-. (    ).`-._.`)  ralsina@kde.org
 (_Y_.)' ._   ) `._`.  " -.-'   KDE Developer (MFCH)
  _..`-'_..-_/ /-'_.'           
(l)-'' ((i).' ((!.'             Buenos Aires - Argentina
Futuaris nisi irrisus ridebis. (Carlton, De rerum comoedia)


 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic