[fpc-devel] "Friend" classes?

Michael Van Canneyt michael.vancanneyt at wisa.be
Tue Mar 15 16:32:19 CET 2005



On Tue, 15 Mar 2005, DrDiettrich wrote:

> I just came about code that uses protected members of other classes,
> defined in other units. In Delphi this possible by a declaration like:
>
> type TFriendClass = class(TNotMyClass);

This is a simple descendent.

>
> After this declaration the protected (and private?) members of
> TNotMyClass are accessible, using TFriendClass as an type alias.
>
> Now my questions:
>
> 1) Is such behaviour also available with FPC? In non-Delphi modes?

Yes. Only protected.

>
> 2) How portable are such "friend" classes? Does there exist some (other)
> standard for this purpose?

The above is a simple descendent, so I'm not sure about this 'friend' ?

>
> 3) What alternatives could be used, so that not all class members must
> be made public, when they shall be used only in specific related units?

? Please explain.

Michael.




More information about the fpc-devel mailing list