28-07-2020, 12:15 PM
السلام عليكم ورحمة الله تعالى وبركاته
قمت بكتابة هذه الوحدة و الغرض منها هو تطبيق لفهم :
1- كيف يتم إنشاء interface في الدلفي
2- عمل class تقوم بوراثة class اخرى + تقوم ب implementation للـ Interface
قمت بكتابة هذا الكود لكن يوجد خطأ في هذا السطر :
وهذا نص الخطأ الذي يظهره الـ compiler :
الكود الخاص بالـ unit الت صممتها :
قمت بكتابة هذه الوحدة و الغرض منها هو تطبيق لفهم :
1- كيف يتم إنشاء interface في الدلفي
2- عمل class تقوم بوراثة class اخرى + تقوم ب implementation للـ Interface
قمت بكتابة هذا الكود لكن يوجد خطأ في هذا السطر :
كود :
TApp = class(TClassA, IMyInterface)
وهذا نص الخطأ الذي يظهره الـ compiler :
كود :
[dcc32 Error] uMyUnit.pas(21): E2291 Missing implementation of interface method IInterface.QueryInterface
[dcc32 Error] uMyUnit.pas(21): E2291 Missing implementation of interface method IInterface._AddRef
[dcc32 Error] uMyUnit.pas(21): E2291 Missing implementation of interface method IInterface._Release
[dcc32 Fatal Error] WorkOnInterface.dpr(6): F2063 Could not compile used unit 'uMyUnit.pas'
Failed
الكود الخاص بالـ unit الت صممتها :
كود :
unit uMyUnit;
interface
type
IMyInterface = Interface(IInterface)
function GetAdd(pX , pY: integer) : integer;
End;
TClassA = class(TObject)
private
FX : integer;
FY : integer;
public
constructor Create(pX, pY : integer);
function GetName: String;
function GetProduit : integer;
end;
TApp = class(TClassA, IMyInterface)
public
constructor Create(pX, pY: integer);
function GetAdd(pX , pY: integer) : integer;
end;
implementation
{ TClassA }
constructor TClassA.Create(pX, pY: integer);
begin
FX:= pX;
FY:= pY;
end;
function TClassA.GetName: String;
begin
Result := 'TClassA';
end;
function TClassA.GetProduit: integer;
begin
Result := FX * FY;
end;
{ TApp }
constructor TApp.Create(pX, pY: integer);
begin
inherited Create(pX, pY);
end;
function TApp.GetAdd(pX, pY: integer): integer;
begin
Result := FX + FY;
end;
end.