delphi - "var"在字段声明上有什么区别?

标签 delphi syntax

下面的SF声明有什么区别?

type
  TMyClass = class(TObject)
  private
    S: String;
  private var
    F: String;
  end;

我问的原因是因为我可以像 F 一样使用 S (不添加 var 关键字)。

他们受到不同的对待吗?

最佳答案

完全没有区别。根据the documentation :

The var keyword is optional. However, if it is not used, then all field declarations must occur before any property or method declarations. After any property or method declarations, the var may be used to introduce any additional field declarations.

关于delphi - "var"在字段声明上有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15213038/

相关文章:

delphi - delphi 7 生成的 MB 文件是什么?

delphi - 将 Canvas 另存为图像

c# - C#'s most effective counterpart to Delphi' s TStringList 是什么?

multithreading - Delphi XE7 Canvas 在线程中拉伸(stretch)

delphi - 在 Delphi 中查找未使用的(又名 "dead")代码

syntax - 为什么有些 Vim 映射在冒号后包含 <C-U>?

javascript - 两个代码之间的差异

Java 原始声明

mysql - 如果没有模型文件,该表如何更新?

c - 不明白这个语法