Delphi 系统[5]关键字和保留字 uses、type

Delphi 系统[5]关键字和保留字 uses、type

1、定义:

  • uses:用于引用一个外部的单元。uses 语句通常放在一个单元的接口部分或实现部分。
  • type:用于声明各种类型。

2、示例:

2.1 uses:

{ 程序文件 中 使用uses }
program Project1;
uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};
begin
end.


{ 单元文件 中 使用uses}
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes;

implementation
uses
  StrUtrls;

end. 

2.2 type:

type

  { 声明接口 }
  IMyInterface = interface
  end;

  { 声明类指针 }
  PMyObject = ^TMyObject;
  
  { 声明类 }
  TMyObject = class(TObject)
  end;

  { 声明结构 }
  TMyRecord = record
  end;

  { 声明函数 }
  TMyFunc = function(I: Integer): string;

  { 声明自定义类型 }
  TCol = (cItemA, cItemB, cItemC);
  TColSet = set of TCol;
  TLatter = 'A' .. 'Z';
  TInt = Integer;

  

创建时间:2021.08.11  更新时间:

博客园 滔Roy https://www.cnblogs.com/guorongtao 希望内容对你所有帮助,谢谢!
原文地址:https://www.cnblogs.com/guorongtao/p/15126822.html