opensubscriber
   Find in this group all groups
 
Unknown more information…

f : fpc-pascal@lists.freepascal.org 23 December 2011 • 4:46PM -0500

Re: [fpc-pascal] Forward declarations
by Tomas Hajny

REPLY TO AUTHOR
 
REPLY TO GROUP




On Fri, December 23, 2011 07:24, Jürgen Hestermann wrote:
> Timothy Groves schrieb:
>> Can anyone think of a situation in which you would *have* to use
>> forward declared functions?  I'm trying to come up with an example for
>> such for my book, and I am drawing a blank.
>>
>
> Well, maybe this one:
>
> -------------------------------------------------------------------
> type      SorterProcType  = function (String1,String2 : shortstring) :
> boolean;
> function CompareIt1(String1,String2 : shortstring) : boolean; forward;
> function CompareIt2(String1,String2 : shortstring) : boolean; forward;
> function CompareIt3(String1,String2 : shortstring) : boolean; forward;
> const SortCriteria : SortProcType = CompareIt1;
>
> -------------------------------------------------------------------
>
> I don't know of another way that you can use one of the "CompareIt1/2/3"
> functions in the const declaration for "SortCriteria" (but maybe there
> is one).

In this case, you could directly include the implementation with the
CompareIt* declaration (unless CompareIt1 needs to access SortCriteria
too, of course - that would change the picture).

Tomas


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@list...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.