[fpc-pascal] 2.1.1 new protected

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Aug 11 15:01:18 CEST 2006


I managed to Copy and Paste the text, for thouse that can't view the
attached image from my previous post...

---------------------------
A private member is invisible outside of the unit or program where
its class is declared. In other words, a private method cannot be
called from another module, and a private field or property cannot
be read or written to from another module. By placing related class
declarations in the same module, you can give the classes access to
one another's private members without making those members more widely
accessible.

A protected member is visible anywhere in the module where its
class is declared and from any descendant class, regardless of
the module where the descendant class appears. A protected method
can be called, and a protected field or property read or written to,
from the definition of any method belonging to a class that descends
from the one where the protected member is declared. Members that are
intended for use only in the implementation of derived classes are
usually protected.

A public member is visible wherever its class can
be referenced
---------------------------

Regards,
  Graeme.


On 8/11/06, Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:
> On 8/11/06, Michael Van Canneyt <michael at freepascal.org> wrote:
> > It seems normal to me that it is not just the current instance.  You KNOW this
> > method is there, in a descendent, so it seems logical that you know that it
> > exists for another instance as well.
>
> Coming from a Delphi background, I disagree here.  As I understood the
> Delphi docs, protected methods are only visible in the current
> instance (decendant), and not instances passed in as parameters.
>
> Reading the docs again, I am not sure what happens when both those
> classes appear in the same unit.  This then becomes like the "friend"
> classes used in C++ and C# and might be allowed in such a case...
> Quite confusing... :-)
>
> Here is a snippet of the Kylix 3 docs:
>
> ------------------------
> ... See attached image, I couldn't cut and paste from CLX....
> ------------------------
>
> Regards,
>   - Graeme -


-- 
There's no place like 127.0.0.1



More information about the fpc-pascal mailing list