eri*_*ick 5 arrays delphi parameters interface tinterfacedobject
我有两个单位,第一个,我的界面:
use personas
interface
type
Tllave = array[0..31] of byte;
Tdatos = array of byte;
ImyInterface = interface(IInterface)
function nombre : string;
function edad : integer;
procedure resetear;
function Proceso(datos : tdatos; cantidad : integer) : integer ;
procedure Iniciar(llave : Tllave);
end;
Run Code Online (Sandbox Code Playgroud)
第二单元,我的对象声明:
use militares
interface
uses personas;
type
Tmilitares = Class(TInterfacedObject, ImyInterface )
public
function nombre : string;
function edad : integer;
procedure resetear;
function Proceso(datos : Tdatos; cantidad : integer) : integer ;
procedure Iniciar(llave : Tllave);
published
constructor create;
end;
implementation
function tmilitares.Proceso(datos : tdatos; cantidad : integer) : integer ; // getting error !!
begin
// ....
end;
procedure tmilitares.Iniciar(llave : Tllave); // getting error!!
begin
// ....
end;
Run Code Online (Sandbox Code Playgroud)
我只在'proceso'函数和'iniciar'过程中收到错误消息:
'Iniciar'的声明与先前
的'Proceso' 声明声明的不同之前的声明不同.
我注意到他们有阵列参数.参数的类型在第一个单元中定义,如果我在第二个单元中定义这些类型,我得到相同的错误,但它在对象的声明中显示.我怎么编译?
Dav*_*nan 10
您没有显示足够的代码,但显然正在发生的是您正在重新定义接口部分的声明和方法的实现之间的违规类型(Tdatos
和Tllave
)Tmilitares
.此重新声明可以是您use
或该militares
单元的实施部分中的另一个单元的形式.
找到其他声明,你就能解决问题.
您在问题末尾的评论是:
如果我在第二个单元中定义这些类型,我得到相同的错误,但它显示在类的声明中.
您尝试重新定义类型的事实表明了理解的问题.类型需要一次性声明一次.一旦定义它们两次,现在有两种不同的不兼容类型.更糟糕的是,他们有相同的名字!定义一次类型并通过uses
语句将其导入其他单元.