Last active
August 30, 2019 17:11
-
-
Save manojnaidu619/f2d70b9ecb66179f2ef889421f1bc8ce to your computer and use it in GitHub Desktop.
Pointer to a function in CPP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int give_max(int x, int y){ | |
return x>y ? x : y; | |
} | |
int main(){ | |
int (*f)(int,int); // Pointer declaration | |
f = give_max; // Pointer initialization with the function name | |
cout << (*f)(3,2); // prints out 3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment