Delphi声明Record变量后直接初始化

 TARec = record
    A1: string;
    A2: string;
  end;

  TBRec = record
    A1: string;
    A2: string;
    ARec: TARec;
  end;

  PAppWindow = ^TAppWindow;
  TAppWindow = Record
    Width, Height : Integer;
    CaptionBarHeight : Integer;
  end;

var
  FARec: TARec = (A1: ''; A2: '');
  BRec: TBRec = (A1: ''; A2: ''; ARec: (A1: ''; A2: ''));
  i: Integer = 100;

  Window : TAppWindow = (Width:800; Height:600; CaptionBarHeight:26);

全局变量可以直接初始化,但是局部变量不允许。

原文地址:https://www.cnblogs.com/yzryc/p/6292706.html