Skip to content

Instantly share code, notes, and snippets.

@Alynva
Created May 21, 2017 23:31
Show Gist options
  • Save Alynva/89acd1c121bcb4a02d9b0ffbd448e1e8 to your computer and use it in GitHub Desktop.
Save Alynva/89acd1c121bcb4a02d9b0ffbd448e1e8 to your computer and use it in GitHub Desktop.
A function as a parameter of another function
#include <iostream>
using namespace std;
int f1(int n) {
return n * 3;
}
int f2(int f(int), int n) {
return f(n) - 2;
}
int main() {
int n;
cin >> n;
cout << f2(f1, n);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment