The definition of a contractual const object does not use the Const keyword, but is considered a const object, for example:
void ReadValue (constint& num) { << num;} int Main (void) { int0; ReadValue (n); // at this point n is considered a contractual constant }
A function pointer is a pointer to a function, declared as follows:
void (*FUNCP) (int x); void (*FUNCP) (int); // two different forms are available
A small example of a function pointer:
//function Pointers#include <stdio.h>void(*FUNCP) ();voidFilefunc ();voidEditfunc ();intMain () {FUNCP=Filefunc; (*FUNCP) (); FUNCP=Editfunc; (*FUNCP) (); return 0;}voidFilefunc () {printf ("filefunc\n");}voidEditfunc () {printf ("editfunc\n");}
The callback function is a kind of function which has the user's own definition and the operating system calls, and the callback function is usually implemented by the function pointer.
//callback function#include <stdio.h>//Defining callback FunctionsvoidFilefunc (intTime ) {printf ("filefunc--%d\n", time);}//implementation of callback functionvoidCallbackintTimesvoid(*print) (int)){ inti; for(i =0; I < times; i++) {print (i); }}voidMainvoid) {Callback (2, Filefunc);}
Contract-type constants, function pointers, callback functions