#include #include using namespace std; void f0(); void f1(); void f2(); void f3(); int main() { void (*const a[])() = { f0, //or &f0, with explicit "address of" operator f1, f2, f3 }; const size_t n = sizeof a / sizeof a[0]; size_t i; //uninitialized variable cin >> i; if (i >= n) { cerr << "input " << i << " must be in the range 0 to " << n - 1 << " inclusive\n"; return EXIT_FAILURE; } a[i](); //or (*a[i])() with explicit dereferencing operator return EXIT_SUCCESS; }