2013-08-28 3 views
0

나는 오류를 받고 있어요 :왜 오류가 발생합니까 구현이 누락 되었습니까?

다음

[DCC Error] Test.pas(10): E2291 Missing implementation of interface method ICoTest64.MyFunc

가 TLB 파일의 코드 조각입니다.

// *********************************************************************// 
// Interface: ICoTest64 
// Flags:  (4416) Dual OleAutomation Dispatchable 
// GUID:  {76CF78FE-22A3-4C0B-B1A9-97634A453AE3} 
// *********************************************************************// 
    ICoTest64 = interface(IDispatch) 
    ['{76CF78FE-22A3-4C0B-B1A9-97634A453AE3}'] 
    function MyFunc(const Range: System.OleVariant): System.OleVariant; safecall; 
    end; 

그리고 여기에 내가 델파이 XE2

문제점은 무엇을 사용하고 implementation = interface

을 말할 수있는 지금까지 구현

unit Test; 

interface 

uses 
    SysUtils, ComObj, ComServ, ActiveX, Variants, Office2000, Excel2000, 
    adxAddIn, Test64_TLB, 
    System.Classes, adxHostAppEvents, Dialogs, StdVcl; 

type 
    TCoTest64 = class(TadxAddin, ICoTest64) 
    protected 
    function MyFunc(var Range: System.OleVariant): System.OleVariant; safecall; 
    end; 

implementation 

function TCoTest64.MyFunc(var Range: System.OleVariant): System.OleVariant; 
begin 
    Result:= 10; 
end; 

end. 

입니까?

답변

6

MyFunc의 함수 매개 변수 목록이 일치하지 않습니다. ICoTest64 인터페이스의 선언은 const 매개 변수를 사용합니다. 그러나 클래스 TCoReporting64에서의 구현은 var 매개 변수를 사용합니다.

인터페이스 선언이 올바른지 가정 할 때, 당신은 따라서 귀하의 코드를 변경해야합니다

type 
    TCoReporting64 = class(TadxAddin, ICoTest64) 
    protected 
    function MyFunc(const Range: System.OleVariant): System.OleVariant; safecall; 
    end; 
+0

예, 그게 바로 그거야, 그것은 지금 컴파일합니다. 나는 어떤 형태의 실명으로 고통 받고 있다고 생각합니다. 거의 모든 코드가 델파이에 의해 자동 생성된다는 것입니다. 그래서'const'와'var' 선언 사이의 차이점을 알지 못했습니다. – Johan