how a function gives a pointer as parameter c++
//example that uses pointer as parameter // function definition to swap the values. void swap(int *x, int *y) { int temp; temp = *x; /* save the value at address x */ *x = *y; /* put y into x */ *y = temp; /* put x into y */ return; }
Source: www.tutorialspoint.com
c++ function pointer as variable
// Here's a macro I use to define a type. // You're welcome to use it, but I'll also show how the type is defined. #define d_typedef_func_ty(return_z, name, ...) typedef return_z (*name)(__VA_ARGS__); d_typedef_func_ty(int, int_2i_f, int, int); // creates a int(*)(int, int) function pointer // which is equivelant to the following: typedef int(*int_2i_f)(int, int);