Einzelnen Beitrag anzeigen

mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.858 Beiträge
 
Delphi 11 Alexandria
 
#7

Re: gibt es Class Procedures in Records?

  Alt 27. Jan 2009, 11:17
Kompilliert zumindes mal:

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

  TMyObject = class
  end;

  PMyRecord = ^TMyRecord;
  TMyRecord = packed Record
    Obj: TMyObject;
    Class Function Create: PMyRecord; static;
  End;

var
  Form1: TForm1;
  Test: PMyRecord;

implementation

{$R *.dfm}

class function TMyRecord.Create: PMyRecord;
var
    p: PMyRecord;
begin
    New(p);
    result := p;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    Test := TMyRecord.Create;
end;

end.
Markus Kinzler
  Mit Zitat antworten Zitat