我的com为什么编译不通过?

Eric_yu 2003-10-17 10:36:42
我写了一个简单的com,代码如下:
unit Unit1;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
Windows, ActiveX, Classes, ComObj;

type
ICalculator=interface
['{46DA26FE-95A7-41A5-9026-C73DEDC12100}']
function Add(x,y:Integer):Integer;safecall;
function Mult(x,y:Integer):Integer;safecall;
end;

type
TCalculator = class(TComObject,ICalculator)
protected
function Add(x,y:Integer):Integer;safecall;
function Mult(x,y:Integer):Integer;safecall;
end;

const
Class_Calculator: TGUID = '{ADEB22B8-86FA-4AAD-9737-881888DCA7C8}';

implementation
uses ComServ;
function Add(x,y:Integer):Integer;safecall;
begin
Result:=x+y;
end;

function Mult(x,y:Integer):Integer;safecall;
begin
Result:=x*y;
end;

initialization
TComObjectFactory.Create(ComServer, TCalculator, Class_Calculator,
'Calculator', '', ciMultiInstance, tmApartment);
end.

但是一编译就有如下错误:
[Error] Unit1.pas(20): Unsatisfied forward or external declaration: 'TCalculator.Add'
[Error] Unit1.pas(21): Unsatisfied forward or external declaration: 'TCalculator.Mult'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

怎么会Unsatisfied呢,哪位高手告诉我一下
...全文
44 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧