jlyu
10/9/2013 - 8:19 AM

callback function pointer

#include <iostream>
using namespace std;


bool updateProcess(int pct)
{
    cout << pct << "% complete...\n";
	return (true);
}

typedef bool (*FuncPtrBoolInt)(int);

void longOperation(FuncPtrBoolInt update)
{
	long upperBound = 10000000;
	for(long i=0; i<upperBound; i++)
	{
		if (i*100 % upperBound == 0)
		{
			update(i*100 / upperBound);
		}
	}
}

int main()
{
	longOperation(updateProcess);
	return 0;
}