常量的 訪問限制
阿新 • • 發佈:2017-05-06
訪問限制 vcl messages std spa obj rtm begin repo
unit Unit5; interface uses 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.
常量的 訪問限制