第一个回调函数示例工程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fx_odyssey/article/details/78970935
//cb.h
typedef void (__stdcall *CBTest)(int n);
void __stdcall ShowNum(int n, CBTest cbTest);

//cb.cpp
#include "cb.h"
#include <stdio.h>
void __stdcall ShowNum(int n, CBTest cbTest)
{
    printf("开始调用回调:%d\n\n", n);
    cbTest(n);
}

//source.cpp
#include "cb.h"
#include <stdio.h>
#include <stdlib.h>
void __stdcall CB(int n)
{
    printf("\t回调函数输出:%d\n\n\n\n", n);
}
int main()
{
    CBTest cb = CB;
    ShowNum(10, cb);
    system("pause");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/fx_odyssey/article/details/78970935