Which of the following statements are correct?
Explanation
Consider the following function:
int foo()
{
    return 5;
}
The syntax for creating a function pointer that takes no arguments and returns an integer is following:
int (*fptr)();
Typedefs can be used to make pointers to functions look more like regular variables:
typedef int (*fptr)();
This defines a typedef called “fptr” that is a pointer to a function that takes no arguments and returns int. Now instead of doing this:
bool validate(int x, int (*fcnPtr)());
You can do this:
bool validate(int nX, fptr f)
More information: Function Pointers

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes