Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
pointer array of functions
#include <cstdlib> #include <iostream> using namespace std; // prototypes int add1(int i); int add2(int i); int add3(int i); // array of fn int (*fn_ptr[])(int) = {add1, add2, add3}; int result; int params[3] = {8, 4, 5}; int main() { result = 0; for (int i = 0; i <= 2; i++) { result += (*fn_ptr[i])(params[i]); } cout << result << endl; return 0; } // Declaration int add1(int i) {return i+1;} int add2(int i) {return i+2;} int add3(int i) {return i+3;}
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
minmax
Print All Paths In Matrix
Bit count in number
cynb
RegExpress
0/1Knapsack
DailyGroceryHisto
HeapSort
Interview Prep
Defining Class Members
Please log in to post a comment.