mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 19:39:33 +02:00
28 lines
573 B
ObjectPascal
28 lines
573 B
ObjectPascal
{$mode objfpc}
|
|
type
|
|
tc = class
|
|
function test(var c: tc): boolean;
|
|
left,right: tc;
|
|
end;
|
|
|
|
testfunc = function(var c: tc):boolean of object;
|
|
|
|
function foreach(var c: tc; p: testfunc): boolean;
|
|
begin
|
|
if not assigned(c) then
|
|
exit;
|
|
end;
|
|
|
|
|
|
function tc.test(var c: tc): boolean;
|
|
begin
|
|
{ if you use @test, the compiler tries to get the address of the }
|
|
{ function result instead of the address of the method (JM) }
|
|
result := foreach(c.left,@tc.test);
|
|
result := foreach(c.right,@tc.test) or result;
|
|
end;
|
|
|
|
|
|
begin
|
|
end.
|