在Delphi中定义其他单位的类型 [英] Defining types from other units in Delphi
本文介绍了在Delphi中定义其他单位的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Var
A : Array [1..4] of Integer;
B : Array [1..4] of Integer;
Begin
A := B;
Won't work as loren-pechtel said here the problem is A and B for me are in different units. So, is there a way to define a type definition from a existing one in another class?
推荐答案
在某个单元的接口块中定义类型,然后通过uses
子句将该单元包括在需要该类型的其他单元中.
Define type in interface block of some unit and then include that unit via uses
clause in other units where you need that type.
unit A;
interface
type
TMyArray = array [1..4] of Integer;
...
当您需要在另一单元中使用TMyArray
时:
When you need to use TMyArray
in another unit:
unit B;
interface
uses A;
...
var x : TMyArray;
这篇关于在Delphi中定义其他单位的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文