Saturday, February 4, 2012

Function Pointer


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);

#{Header}

Hi,
    It's late night in 4th feb. I was wasting time re inventing wheels , i mean i was working on some basic c++ codes. I have practiced them a number of times, but at present i couldn't remember them. I think it's time to make a note of all these. So I am creating this blog for myself. I will post all cpp related stuffs which i feel necessary for me. If you find this site useful, please get in touch. I would love to see you as a contributer.

Regards
Rwik