数组 – 当编译器看起来相同时,为什么编译器说实现“与之前的声
发布时间:2020-12-15 04:16:53 所属栏目:大数据 来源:网络整理
导读:我有两个单位, 第一个,我的界面: use personasinterfacetype Tllave = array[0..31] of byte; Tdatos = array of byte; ImyInterface = interface(IInterface) function nombre : string; function edad : integer; procedure resetear; function Proceso(d
我有两个单位,
第一个,我的界面: 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; 第二单元,我的对象声明: 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; 我只在’proceso’函数和’iniciar’过程中收到错误消息: “Iniciar”的声明与之前的声明不同 我注意到他们有阵列参数.参数的类型在第一个单元中定义,如果我在第二个单元中定义这些类型,我得到相同的错误,但它在对象的声明中显示.我怎么编译? 解决方法
您没有显示足够的代码,但显然正在发生的是您正在重新定义接口部分中Tmilitares声明与方法实现之间的违规类型(Tdatos和Tllave).这种重新声明可以是您使用的另一个单位的形式,也可以是军事单位的实施部分.
找到其他声明,你就能解决问题. 您在问题末尾的评论是:
您尝试重新定义类型的事实表明了理解的问题.类型需要一次性声明一次.一旦定义它们两次,现在有两种不同的不兼容类型.更糟糕的是,他们有相同的名字!定义一次类型并通过uses语句将其导入其他单元. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |