Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does C++ Builder and Delphi class names begin with the letter T?

Like classes TObject, TForm, TComponent.

Why do they begin with the letter "T"?

What is the meaning of "T"?

like image 500
dabin L Avatar asked Dec 03 '22 09:12

dabin L


1 Answers

T stands for "type", and it is used as a conventional prefix for non-built-in types in general, not only for class types:

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

However, the conventional prefixes for pointer types, exception types, and interface types are P, E, and I, respectively:

type
  PPersonRec = ^TPersonRec;
  ESyntaxError = class(EScriptException);
  ISoundPlayer = interface
    {...}
  end;

There are several other conventions, like F for fields:

type
  TCar = class
  strict private
    FModel: string;
    FColor: TColor;
    FWeight: Double;
  end;

And A for arguments:

procedure MyShowMessage(const AMessage: string; AIconType: TIconType);

Sometimes people use L for local variables:

procedure MyShowMessage(const AMessage: string; AIconType: TIconType);
var
  LCaption: string;
  LIcon: HICON;
begin

end;
like image 50
Andreas Rejbrand Avatar answered Dec 20 '22 00:12

Andreas Rejbrand