Classes / Constructors

type
  TMan = class
  private
    class var FNextId: Integer;
    class function GetLastDbId: Integer;
  public
    Id: Integer;
    constructor Create;
    //type initializer: runs once
    //before the first use of the class
    class constructor Create;
  end;

class constructor TMan.Create;
begin
  FNextId := GetLastDbId;
end;

class function TMan.GetLastDbIdInteger;
begin
  //some implementation
  Result := 0;
end;

constructor TMan.Create;
begin
  Inc(FNextId);
  Id := FNextId;
end;

var
  Man: TMan;
begin
  Man := TMan.Create;
  //man.Id is 1

  WriteLn('man.Id is ', Man.Id);
end.