回调函数

#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);
    return 0;
}

posted @ 2009-03-08 16:09  小 楼 一 夜 听 春 雨  阅读(133)  评论(0编辑  收藏  举报