C语言的函数指针作为参数传递。

typedef  int (* Invoke)(int , int);
int max (int a, int b){
    return a>b ? a:b;
}
int dealWith(Invoke invoke){
    int c = invoke(3,5);
    c = c + 8;
    return c;
}
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        Invoke invoke = max;
        NSLog(@"%d",dealWith(invoke));
    }
    return 0;
}

你可能感兴趣的:(C语言的函数指针作为参数传递。)