Original Post
When I first learnt C++ and encountered function pointers, it was one of those things I decided were fairly useful but too dificult for me as a newb to understand. Over the past few days though, I have gone back and learnt the in's and out's of the syntax and how FP's work. However, I have encountered a problem. Lets say we have a pointer, pX, which points to a function, fY. fY takes a single argument, an int. Is it possible, to set the arguments which are passed to fY when pX is initialised so that pY can be called without the need to specifically pass the aguments when it is called using pX? Il demonstrate what i mean: Of course the above code doesnt work, but you get the idea of what im trying to achieve. And I'm not even sure if such a thing is possible to do. However, if it isn't, I would much appreciate suggestions for a work-around, or a way I can emulate this.
int M; //This is what we want to be passed to fY whenever it is called through pX
int fY(int Z);//Our function itself.
int (*pX)(int) = fY(M);//pX is initialised to fY with the argument M
pX();//call fY through pX, meaning that M is passed as an argument