1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
{ %VERSION=1.1 }
{$ifdef fpc}
{$mode objfpc}
{$endif}
type
ITest = interface(IUnknown)
procedure DoSomething;
end;
TMyClass = class(TInterfacedObject, ITest)
procedure DoSomething;
end;
var
i : longint;
procedure TMyClass.DoSomething;
begin
inc(i);
end;
procedure DoTest(const ATest: ITest);
begin
ATest.DoSomething;
end;
procedure DoTest2(ATest: ITest);
begin
ATest.DoSomething;
end;
var
c: ITest;
begin
i:=0;
c := TMyClass.Create;
DoTest(c);
DoTest2(c);
if i<>2 then
begin
writeln('Problem with passing interfaces as parameters');
halt(1);
end;
end.
|