Recent

Author Topic: Inherited Constructor (add a Parameter)?  (Read 587 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 616
  • Compiler Developer
Re: Inherited Constructor (add a Parameter)?
« Reply #15 on: October 10, 2019, 09:22:54 am »
Code: Pascal  [Select]
  1. MyList.Create(S));
  2. TMyList.Create(S));
  3.  
The first variant simply calls the constructor as a normal method.
The second is a real constructor call with compiler magic to instantiate a new instance using TMyList.NewInstance before calling the constructor.

bytebites

  • Full Member
  • ***
  • Posts: 205
Re: Inherited Constructor (add a Parameter)?
« Reply #16 on: October 10, 2019, 09:31:54 pm »
Class helper could help too.
Code: Pascal  [Select]
  1. TMemohelper= class helper for TMemo
  2.    procedure addlines(S: string);
  3.  end;
  4.  
  5.  
  6. procedure TMemohelper.Addlines(S:string);
  7. var list:TStringlist;
  8. begin
  9.   list:=TStringlist.create;
  10.   list.Delimiter:=';';
  11.   list.DelimitedText := S;
  12.   Lines.AddStrings(list);
  13.   list.free;
  14. end;