Skip to content

Instantly share code, notes, and snippets.

@manojnaidu619
Last active August 30, 2019 17:11
Show Gist options
  • Save manojnaidu619/f2d70b9ecb66179f2ef889421f1bc8ce to your computer and use it in GitHub Desktop.
Save manojnaidu619/f2d70b9ecb66179f2ef889421f1bc8ce to your computer and use it in GitHub Desktop.
Pointer to a function in CPP
#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