Per Jespersen

Per Jespersen

  • NA
  • 23
  • 35.3k

Passing function as argument

Mar 9 2011 5:10 AM

I know this won't work, but if you can see what I'm trying to do, I would like help to make it work:

void f1(float input){

        listbox.Add(input*1);

}


void f2(float input){

        listbox.Add(input*2);

}


void f3(function *inputFunction, argument *inputArgument){

        inputFunction(inputArgument);

}


void main(){

        f3(f1 , 1);

}


How do I make it possible to call f3, so that it has acces to either f1 or f2, with whatever argument I want?

Answers (3)