Einzelnen Beitrag anzeigen

DieDolly

Registriert seit: 22. Jun 2018
2.175 Beiträge
 
#2

AW: Wie Methode als Pointer übergeben?

  Alt 22. Jul 2018, 12:08
Vielleicht hilft das

Delphi-Quellcode:
 type
   TFunctionParameter = function(const value : integer) : string;
...
function One(const value : integer) : string;
begin
   result := IntToStr(value) ;
end;
function Two(const value : integer) : string;
begin
   result := IntToStr(2 * value) ;
end;
function DynamicFunction(f : TFunctionParameter) : string;
begin
   result := f(2006) ;
end;
...
//Example usage:
var
   s : string;
begin
   s := DynamicFunction(One) ;
   ShowMessage(s) ; //will display "2006"
   s := DynamicFunction(Two) ;
   ShowMessage(s) ; // will display "4012"
end;
https://www.thoughtco.com/function-o...ameter-1057606
  Mit Zitat antworten Zitat