Function Pointer assigned



Function pointer assigned
Smart pascal source code
type TMyFunc = function(i: Integer): String; type TMyClass = class FEvent: TMyFunc; function DoConv(i: Integer): String; end; function TMyClass.DoConv(i: Integer): String; begin Result := '[' + IntToStr(i) + ']'; end; var o := TMyClass.Create; if Assigned(o.FEvent) then WriteLn(o.FEvent(1)) else WriteLn('Unassigned'); o.FEvent := o.DoConv; if Assigned(o.FEvent) then WriteLn(o.FEvent(2)); var e: TMyFunc; if Assigned(e) then WriteLn(e(3)) else WriteLn('Unassigned'); e := o.DoConv; if Assigned(e) then WriteLn(e(4)); e := nil; o.FEvent := e; if Assigned(e) then WriteLn(e(5)) else WriteLn('Unassigned'); {<<< RESULT - CONSOLE LOG >>> ----------------------------- Unassigned [2] Unassigned [4] Unassigned ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}