Delphi E2003未声明的标识符:';ITestInterfataUnit';
这看起来是个愚蠢的问题,但我已经为此挣扎了一段时间。我有两个单位。一个是带有声明接口的单元,另一个是我想要实现该接口的表单。代码:Delphi E2003未声明的标识符:';ITestInterfataUnit';,delphi,Delphi,这看起来是个愚蠢的问题,但我已经为此挣扎了一段时间。我有两个单位。一个是带有声明接口的单元,另一个是我想要实现该接口的表单。代码: unit ITestInterfata; interface implementation type ITestInterfataUnit = interface ['{A0CD69F8-C919-4D2D-9922-A7A38A6C841C}'] procedure Intrare(s : string); end; end.
unit ITestInterfata;
interface
implementation
type
ITestInterfataUnit = interface
['{A0CD69F8-C919-4D2D-9922-A7A38A6C841C}']
procedure Intrare(s : string);
end;
end.
主要表格单位:
unit frameTestInterfata;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, ITestInterfata;
type
TformaTestInterfata = class(TForm, ITestInterfataUnit)
Button1: TButton;
private
{ Private declarations }
public
{ Public declarations }
procedure Intrare(s: string);
end;
var
formaTestInterfata: TformaTestInterfata;
implementation
{$R *.dfm}
{ TformaTestInterfata }
procedure TformaTestInterfata.Intrare(s: string);
begin
ShowMessage('asdf');
end;
end.
如果我使用CTRL键并单击ItestInterfatunit
,它会将我带到正确位置的正确单元。我看到这里正在讨论这样的问题,我已经尝试了所有我认为可以解决的方法
- 再次创建项目
- 关闭并打开DelphiIDE
- 检查接口单元是否在主窗体的
中声明uses
- 确保我给该单元起了一个名字,这样就不会有其他同名的.dcu了李>
ITestInterfataUnit
,因此ITestInterfataUnit
在其他单元中不可见
报告说:
接口部分声明客户端可用的常量、类型、变量、过程和函数。也就是说,发送给希望使用此单元元素的其他单元或程序。这些实体被称为公共实体,因为其他单元中的代码可以访问它们,就好像它们是在单元本身中声明的一样
除了公共过程和函数的定义外,实现部分可以声明单元专用的常量、类型(包括类)、变量、过程和函数。也就是说,与接口部分不同,在实现部分声明的实体对其他单元是不可访问的
您必须在接口部分定义ITestInterfatunit
unit ITestInterfata;
interface
type
ITestInterfataUnit = interface
['{A0CD69F8-C919-4D2D-9922-A7A38A6C841C}']
procedure Intrare(s : string);
end;
implementation
end.
仅导出单元的“接口”部分中定义的符号,以便在其他单元中可见。您在实现部分定义了符号
ITestInterfataUnit
,因此ITestInterfataUnit
在其他单元中不可见
报告说:
接口部分声明客户端可用的常量、类型、变量、过程和函数。也就是说,发送给希望使用此单元元素的其他单元或程序。这些实体被称为公共实体,因为其他单元中的代码可以访问它们,就好像它们是在单元本身中声明的一样
除了公共过程和函数的定义外,实现部分可以声明单元专用的常量、类型(包括类)、变量、过程和函数。也就是说,与接口部分不同,在实现部分声明的实体对其他单元是不可访问的
您必须在接口部分定义ITestInterfatunit
unit ITestInterfata;
interface
type
ITestInterfataUnit = interface
['{A0CD69F8-C919-4D2D-9922-A7A38A6C841C}']
procedure Intrare(s : string);
end;
implementation
end.
你救了我很多神经。非常感谢。你救了我很多神经。非常感谢。