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.
本文来自博客园,作者:del88,转载请注明原文链接:https://www.cnblogs.com/del88/p/6817184.html