    #include <iostream>
    #include <cstdlib>
    #include <stdarg.h>

    typedef int (*ptrFunc) ( int, ... );

    int product ( int, ... );
    int sum     ( int, ... );

    int main(void)
    { ptrFunc pf;

      pf = product;
      cout << (*pf) (3, 4, 12, 11) << endl;
      cout << (*pf) (4, 4,  2, 11, 9) << endl;
      pf = sum;
      cout << (*pf) (3, 4, 12, 11) << endl;
      cout << (*pf) (4, 4,  2, 11, 9) << endl;

      return EXIT_SUCCESS;
    }

    int product (int x, ... )
    { va_list arg;
      int all = 1;

      va_start(arg,x);
      for (int i = 0; i < x; i++)
       all = all * va_arg(arg, int);
      va_end(arg);
      return all;
    }

    int sum (int x, ... )
    { va_list arg;
      int all = 0;

      va_start(arg,x);
      for (int i = 0; i < x; i++)
       all = all + va_arg(arg, int);
      va_end(arg);
      return all;
    }