Skip to content

Instantly share code, notes, and snippets.

@Codeplaza
Created November 5, 2013 08:04
Show Gist options
  • Save Codeplaza/7315462 to your computer and use it in GitHub Desktop.
Save Codeplaza/7315462 to your computer and use it in GitHub Desktop.
// pointer to functions
#include <iostream>
using namespace std;
int addition (int a, int b)
{ return (a+b); }
int subtraction (int a, int b)
{ return (a-b); }
int operation (int x, int y, int (*functocall)(int,int))
{
int g;
g = (*functocall)(x,y);
return (g);
}
int main ()
{
int m,n;
int (*minus)(int,int) = subtraction;
m = operation (7, 5, addition);
n = operation (20, m, minus);
cout <<n << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment