#include <iostream>
typedef int (*TMyFunctionPointer)(int, int);
int Add(int a, int b)
{
return a + b;
}
int SomeFunctionThatTakesAFunctionPointer(int (*myFunctionPointer)(int a, int b))
{
return myFunctionPointer(1, 2);
}
int TypeDefVersion(TMyFunctionPointer myFunctionPointer)
{
return myFunctionPointer(1, 2);
}
int main(int argc, const char* argv[])
{
std::cout << SomeFunctionThatTakesAFunctionPointer(Add) << std::endl;
std::cout << TypeDefVersion(Add) << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdHlwZWRlZiBpbnQgKCpUTXlGdW5jdGlvblBvaW50ZXIpKGludCwgaW50KTsKCmludCBBZGQoaW50IGEsIGludCBiKQp7CglyZXR1cm4gYSArIGI7Cn0KCmludCBTb21lRnVuY3Rpb25UaGF0VGFrZXNBRnVuY3Rpb25Qb2ludGVyKGludCAoKm15RnVuY3Rpb25Qb2ludGVyKShpbnQgYSwgaW50IGIpKQp7CglyZXR1cm4gbXlGdW5jdGlvblBvaW50ZXIoMSwgMik7CQp9CgppbnQgVHlwZURlZlZlcnNpb24oVE15RnVuY3Rpb25Qb2ludGVyIG15RnVuY3Rpb25Qb2ludGVyKQp7CglyZXR1cm4gbXlGdW5jdGlvblBvaW50ZXIoMSwgMik7Cn0KCmludCBtYWluKGludCBhcmdjLCBjb25zdCBjaGFyKiBhcmd2W10pIAp7CglzdGQ6OmNvdXQgPDwgU29tZUZ1bmN0aW9uVGhhdFRha2VzQUZ1bmN0aW9uUG9pbnRlcihBZGQpIDw8IHN0ZDo6ZW5kbDsKCXN0ZDo6Y291dCA8PCBUeXBlRGVmVmVyc2lvbihBZGQpIDw8IHN0ZDo6ZW5kbDsKCglyZXR1cm4gMDsKfQ==