Re: passing function as a parameter to another function
this: int (*fn)() is declaring fn as a pointer to a function which takes no parameters and returns an int.
But in your code you still refer to it as add(), you need to call fn().
Function points are a nice, but can get complex in C++. An other option would be 'Functor' classes (classes which override the () operator) which would do a similar thing.
Re: passing function as a parameter to another function
so far so gud thanx the program ran....
but I have one question....
pointer to a variable means a thing which points to the variable i.e.it stores the address of the variable...right?
What does pointer to a function imply?
a variable which is pointer to a function stores the address of the function????
but the function is made at run time...correct me if I am wrong?
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.