Created
May 21, 2017 23:31
-
-
Save Alynva/89acd1c121bcb4a02d9b0ffbd448e1e8 to your computer and use it in GitHub Desktop.
A function as a parameter of another function
This file contains 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 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