[fpc-pascal] Overloaded functions

Vojtěch Čihák vojtech.cihak at atlas.cz
Sat Oct 28 23:27:29 CEST 2017

Overloading means that you have functions with the same name but different parameter (or param. list). You can have different return type for each parameter but you can never have the same parameters.
> Od: Darius Blaszyk <dhkblaszyk at zeelandnet.nl>
> Komu: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Datum: 28.10.2017 22:58
> Předmět: [fpc-pascal] Overloaded functions

I have a problem with overloaded functions. I defined these functions:
function val_(name: string): string;
function val_(name: string): boolean;
function val_(name: string): integer;
function val_(name: string): double;

  res: boolean;
  res := val_(option_variable);

I get the following error: Error: Incompatible types: got "ShortString" expected "Boolean". So for some reason the compiler is looking at the first function. The mode is objfpc and I turned ansistrings off. I tested by adding the overload modifier but without result. What else could I try or do? Or is overloading only allowed for different parameter lists?

Rgds, Darius
 fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20171028/404f05a3/attachment.html>

More information about the fpc-pascal mailing list