Just like variables, functions also has their own memory addresses . So we have pointers for them too.
void (*fPtr)();// a void function pointer declaration which takes no args.
fPtr = &myFunc;
(*fPtr)();
int (*ptr2)(int,int);// a int function pointer declaration which takes 2 int args.
ptr2 = &myOtherFunc;
int i=0,j=2;
int result = (*ptr2)(i,j);
void (*fPtr)();// a void function pointer declaration which takes no args.
fPtr = &myFunc;
(*fPtr)();
int (*ptr2)(int,int);// a int function pointer declaration which takes 2 int args.
ptr2 = &myOtherFunc;
int i=0,j=2;
int result = (*ptr2)(i,j);
No comments:
Post a Comment