不,等於是一個賦值,因爲這是如何分配常量。舉個例子,
const Pi = 3.1415;
或
const s = 'This is an example';
另外還有 '類型的常量':
const Pi: extended = 3.1415;
在上面的片段中,我們定義了持有的函數定義的常簽字function(const S: String): String
。我們將(兼容)功能SomeVariable1
分配給它。
SomVariable1
,必須及早在代碼中定義的,例如,作爲
function SomeVariable1(const S: String): String;
begin
result := S + '!';
end;
請看下面的例子:
function SomeVariable1(const S: String): String;
begin
result := S + '!';
end;
const
function1: function(const S: String): String = SomeVariable1;
procedure TForm1.FormCreate(Sender: TObject);
begin
caption := function1('test');
end;
Andreas解釋**這是什麼**。但我看不到這是什麼。項目中是否啓用了「可指定類型常量」? – 2011-04-07 15:57:47