Skip to content

Instantly share code, notes, and snippets.

@misterpoloy
Created January 10, 2020 23:54
Show Gist options
  • Save misterpoloy/f9c0550e136f1e61c6ebc7bcb17e4e11 to your computer and use it in GitHub Desktop.
Save misterpoloy/f9c0550e136f1e61c6ebc7bcb17e4e11 to your computer and use it in GitHub Desktop.
Function Pointer
// https://www.youtube.com/watch?v=LW8Rfh6TzGg&list=PL2_aWCzGMAwLZp6LMUKI3cc7pgGsasm2_&index=5
#include <iostream>
int add(int a, int b) {
return a + b;
}
int main() {
int c;
int (*p)(int, int); // the signature values must coinicde.
p = &add; // p = add // Derefference the function name
c = (*p)(2, 3); // p(2,3) // Casting value and using function.
std::cout << "The sum is: \n" << c << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment