Jump to content

Sam Witse

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Dalija, Thanks, clear explanation. Any idea how I could define a working 'polymorfic property' ?
  2. This is exactly what I'm trying to do: class function GetChildID: integer; virtual; abstract; is a virtual class function. But the Child-version of this class function is not found!
  3. Hi Delphi addicts, I want to create an "inherited class property". - I define a class property in Master - Define a local getter in Master, because a getter must be static - Define an abstract class procedure, called by the getter - Implement the class procedure in Child Writing it in Delphi and compiling it, all goes well. When executing the code, the getter raises an abstract error when calling the class procedure. What am I missing? Is there a way to define inheritable polymorf class properties? unit Unit1; interface type TMaster = class private class function GetMasterId: integer; static; {MUST be a static method for a property getter} protected class function GetChildID: integer; virtual; abstract; public class property id: integer read GetMasterId ; end; TChild = class(TMaster) protected class function GetChildID: integer; override; end; implementation { TMaster } class function TMaster.GetMasterId: integer; begin result := GetChildID ; { <= at this point I get an abstract error} end; { TChild } class function TChild.GetChildID: integer; begin result := 1 end; end. procedure TForm2.Button1Click(Sender: TObject); begin Edit1.Text := inttostr(TChild.id) { <= Calling the Child's property} end;
×