天天看點

回調函數

#include <iostream>

using namespace std;

// 定義了一種函數指針類型callback

typedef int (*callback)(int, int);

int mytest(int a, int b)

{

    cout<<a<<"/t"<<b<<endl;

    return 0;

}

void testcallback(callback my)

    int a = 1;

    int b = 1;

    if(my != null)

        my(a,b);

    return;

int main()

    callback myfuc = null;

    myfuc = mytest;

    testcallback(myfuc);