// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>

using namespace std;

typedef void (*callbackfunc)(...);

void p(int ix, callbackfunc *f)
{
    if(ix < 1)
    {
        f[ix](1);
    }
    else
    {
        f[ix](1,2);
    }
}

void f1(int a)
{
    cout << "f1: " << a << endl;
}

void f2(int a,int b)
{
    cout << "f2: " << a << " " << b << endl;
}

int main()
{
    callbackfunc f[2];
    f[0] = (callbackfunc)f1;
    f[1] = (callbackfunc)f2;
    for(int i = 0; i < 2; i++) p(i, f);
    return 0;
}
