A function pointer is still a pointer, meaning it's still a variable.
A function pointer is still a pointer, meaning it's still a variable. If you want a variable to be visible from several source files, the simplest solution is to declare it extern in a header, with the definition elsewhere. In a header: extern void (*current_menu)(int); In one source file: void (*current_menu)(int) = &the_func_i_want.
Ty, now it works – user1106072 Dec 19 '11 at 14:53 the ampersand isn't strictly necessary – Dave Dec 19 '11 at 16:27 That is true, @Dave. In C, it's a stylistic choice of mine for clarity. In C++ it's sometimes required in certain template contexts, so I just do it for consistency.
– Drew Dormann Dec 19 '11 at 17:06.
It's often helpful to use typedef with function pointers, so you can name the type to something descriptive: typedef void (*MenuFunction)(int); Then you would have a global variable of this type, probably in menus. C, and declared (with extern) in menus. H: static void my_first_menu_function(int x) { printf("the menu function got %d\n", x); } MenuFunction current_menu = my_first_menu_function; From main.
C, you can then do: #include "menu. H" current_menu(4711); to call whatever function is currently pointed at by current_menu.
Very true! Function is also available if you have access to boost or C++11. – Drew Dormann Dec 19 '11 at 15:12.
A pointer function itself does not have a function definition. It's nothing more than a pointer to a type, the type being specified by the return type of the function and the parameter list. What you need to do is define a function with the same parameter list and return type, then use your pointer function to hold that function's address.
You can then call the function through the pointer.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.