Showing posts with label callback. Show all posts
Showing posts with label callback. Show all posts

20130421

How to use callback function pointer in cpp/C/C++

Program for callback /function pointer in CPP/C/C++

What is function pointers?As we know a pointer is a special variable that folds the address of another variable.
Function pointer is also  a pointer that hold the address of a function.
Int array[10]; // here array is a constant pointer to a 10 element array. That is constant pointer to first element of array.
Can we declare a non-constant pointer to a function? Yes we can .
Int (*funcPtr)();//funcPtr is a pointer to a function that takes no arguments and returns an integers.//parenthesis is must here as we are not assigning the return type.
Int (*funcPtr)(int,int);//funcPtr is a pointer to a function that takes two arguments and returns an integers.