首页 > 代码库 > 常量的 访问限制

常量的 访问限制

unit Unit5;interfaceuses  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;type  TForm5 = class(TForm)    Button1: TButton;    Memo1: TMemo;    procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;TBoy = class  const    abc = boy;end;TGirl = class  const    abc = girl;end;const  abc = 真全局;var  Form5: TForm5;implementation{$R *.dfm}procedure TForm5.Button1Click(Sender: TObject);begin  Memo1.Lines.Add(abc);  Memo1.Lines.Add(TBoy.abc); //类常量 是有 访问限制的  Memo1.Lines.Add(TGirl.abc)end;procedure TForm5.FormCreate(Sender: TObject);begin  ReportMemoryLeaksOnShutdown := True;end;end.

 

常量的 访问限制