Function pointer array
#include <iostream> using namespace std; double sum(const double, const double); double product(const double, const double); double subtract(const double, const double); double (*pFunc[])(const double, const double) { sum, product, subtract }; int main(int args, char** argv) { double a = atol(argv[1]), b = atol(argv[2]); double result = pFunc[0](a, b); cout << fixed << "Sum=" << result << endl; result = pFunc[1](a, b); cout << "Product=" << fixed << result << endl; result = pFunc[2](a, b); cout << "Subtract=" << fixed << result << endl; } double subtract(const double a, const double b) { return a - b; } double product(const double a, const double b) { return a * b; } double sum(const double a, const double b) { return a + b; }