Zorgoth
January 19th, 2009, 02:23 AM
Ok, this sounds ridiculous. In fact, it is ridiculous. But I want to pass by reference a pointer, which is to pointers, which are to functions of doubles returning doubles in C++. I've tried virtually every possible combination of *s, and every time I get a compiler error. What should I do here?
snova
January 19th, 2009, 02:37 AM
Typedefs are your friend. :)
A function pointer:
typedef double (*funcptr)(double);
A pointer to a function pointer:
typedef funcptr* funcptrptr;
A function that takes a pointer to a function pointer:
double otherfunc(funcptrptr tmp, double y);
Quick example:
int main()
{
funcptr ptr = some_func;
funcptrptr ptr2 = &ptr;
double z = other_func(ptr2, 4.2);
printf("%f\n", z);
}
Zorgoth
January 19th, 2009, 02:50 AM
Thanks!
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.