Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello Everyone,

can you please explain the difference between function pointers and pointer to function?

As I understand function pointer is a pointer variable that stores address of a function however pointer to a function is a function which takes function pointer as an argument.


Correct me if i am wrong.


Regards,
Joy
Posted
Updated 1-Jun-17 2:36am

They're synonymous - "a function pointer" and "a pointer to a function" describe an object that can hold the address of a function.
 
Share this answer
 
Comments
nv3 12-Dec-13 7:43am    
5.
BobJanova 12-Dec-13 9:28am    
Indeed. In fact this is a general thing, 'pointer to X' and 'X pointer' are two ways of saying the same thing - e.g. int* is either 'pointer to integer' or 'integer pointer'.
Not at all. It is both the same: both are pointers, but strong typing is key to avoid problems.

On Windows often used with GetProcAdress and LoadLibrary.

A function which takes a pointer is a normal function. For example: the most string functions are working with pointers to char arrays (aka strings).
 
Share this answer
 
Comments
Richard MacCutchan 1-Jun-17 9:15am    
Look at the date of the question.
Richard Deeming 1-Jun-17 9:16am    
Did you notice that this question was solved in 2013? It only appeared on the "active" list because of solution #3.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900