>> Is there any how to do it?

You can use advanced record syntax and do something like this:

type
  TRec = record
    Numero: Integer;
    Nome: String;
    class function Create(ANumero: Integer; const ANome: string):
TRec; static; inline;
  end;

...

class function TRec.Create(ANumero: Integer; const ANome: string): TRec;
begin
  with Result do
  begin
    Numero := ANumero;
    Nome := ANome;
  end;
end;

...

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowTRec(TRec.Create(1, 'Pascal'));
end;

PS: In Delphi advanced records can have constructors but not yet in
FPC. A static class function can easily replace them.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to