[Lazarus] TImage - Getting image properties in 'canvas space'

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Apr 19 13:09:11 CEST 2012


Alberto Narduzzi schrieb:
>>> But often (depending on the compiler) the mere declaration
>>> of an empty derived class allows to access protected members of the base
>>> class.
>> What does depending on the compiler mean? The compiler is obviously FPC.
>> If it is really true that you can access protected members in that way 
>> (like Svens message suggests) I consider this a bug.
>> Like Mattias said, protected is of no real use in that case and we can 
>> just declare all non private members public.
> 
> I guess this must be considered a bug.

It's not a bug, it's a feature (of Delphi ;-)

> You can indeed access protected 
> members of parent classes, but only from within the (your derived) class 
> members themselves, not from the outer world.
> At least this I believe to e the meaning of having protected (me and my 
> friends only), together with public (everybody) and private (me and only 
> me).

Apropos "friends": the C++ visibility model is different from the Delphi 
model. In Delphi classes the visibility applies to *unit level*, i.e. 
*all* code in the same unit can access protected (and private?) members 
of the declared classes. This behaviour can be modified with the later 
added "strict private/protected" visibility, which applies to *class* 
level. Similar to C++, where "friend" classes can be added to a class 
declaration, a dummy declaration of a derived class makes all protected 
members of the base class visible in the same *unit*. Similar but not 
identical.

DoDi





More information about the Lazarus mailing list