delphi - 为什么 C++ Builder 和 Delphi 类名以字母 T 开头?

标签 delphi c++builder

像类 TObject、TForm、TComponent。

为什么它们以字母“T”开头?

“T”是什么意思?

最佳答案

T代表“类型”,它通常用作非内置类型的常规前缀,而不仅仅是类类型:

type
  TFileName = type string; // string
  TErrorCode = 1..100; // subrange type
  TCarSize = (csSmall, csMedium, csLarge); // enumeration
  TCarSizes = set of TCarSize; // set
  TPersonRec = record // record
    FirstName: string;
    LastName: string;
    Age: Integer;
  end;
  TSuperBitmap = class(TBitmap) // class
    {...}
  end;
  TDeviceData = array[0..1023] of Byte; // static array
  TLogProc = procedure(const AMessage: string; AKind: TLogKind); // procedural type
  // and so on

但是,指针类型、异常类型和接口(interface)类型的常规前缀是 P , E , 和 I , 分别:
type
  PPersonRec = ^TPersonRec;
  ESyntaxError = class(EScriptException);
  ISoundPlayer = interface
    {...}
  end;

还有其他几种约定,例如 F对于字段:
type
  TCar = class
  strict private
    FModel: string;
    FColor: TColor;
    FWeight: Double;
  end;

A论据:
procedure MyShowMessage(const AMessage: string; AIconType: TIconType);

有时人们使用 L对于局部变量:
procedure MyShowMessage(const AMessage: string; AIconType: TIconType);
var
  LCaption: string;
  LIcon: HICON;
begin

end;

关于delphi - 为什么 C++ Builder 和 Delphi 类名以字母 T 开头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62446529/

相关文章:

delphi - Delphi XE2 中的 XML 数据绑定(bind)向导到哪里去了?

macos - Firemonkey OS X - 请求提升权限

delphi - 我可以找出记事本中相对于桌面窗口的当前打字坐标吗

C++ Builder 2009 - 简单的整数列表

delphi - Delphi/C++Builder 的网络广播播放器组件

delphi - 拖放时移动图像

delphi - 从字符串中删除所有非标准文本字符

c++ - 如何引用连续的组件(button1、button2 等)?

c++ - 为什么我的代码不显示我的 TButton 数组?

dll - 使用 C++Builder 在 DLL 中创建窗体