Recent

Author Topic: Error with overloaded method  (Read 1598 times)

Neuromancer

  • New Member
  • *
  • Posts: 44
    • My personal website
Error with overloaded method
« on: May 04, 2016, 11:02:37 am »
Hello,

I wrote the following class with an overloaded procedure :
Code: Pascal  [Select][+][-]
  1. TSerialSizer = class(TInterfacedObject, ISerializer)
  2.     protected
  3.         FLength : Integer;
  4.     public
  5.         constructor Create;
  6.         procedure IO(AValue : PChar); overload;
  7.         procedure IO(AValue : PSmallInt); overload;
  8.         procedure IO(AValue : PInteger); overload;
  9.         procedure IO(AValue : PString); overload;
  10.         function GetLength : Integer;
  11.     end;

Code: Pascal  [Select][+][-]
  1. procedure TSerialSizer.IO(AValue : PString);
  2. begin
  3.     IO(FLength);
  4.     Inc(FLength, Length(AValue^));
  5. end;

I get the following error :
Quote
/home/jerome/Projects/pascal/mylibs/serialization/serialsizer.pas(52,15) Error: Incompatible type for arg no. 1: Got "LongInt", expected "PString"

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11458
  • FPC developer.
Re: Error with overloaded method
« Reply #1 on: May 04, 2016, 11:05:53 am »
You pass flength, which is integer and there is no overload for integer, so what do you exactly expect ?

 

TinyPortal © 2005-2018