热门搜索 :
考研考公
您的当前位置:首页正文

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;
}
Top