Run Code
|
API
|
Code Wall
|
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
Dulce enredo p1
Bitfield too small to hold all enum values
Search in a rotated sorted array
BinSearch
error
typedef char*
ReplaceGreaterSum in BST
SIP_parser_with_std_regex_need_help_to_improve_it.cc
Summation Of Primes
begin_end.cpp