回调函数小例


#include "stdafx.h"

typedef int(__stdcall *ptr)(char *p); // 声明Callback 类型的函数指针

int A(char *p){
std::cout<<p<<std::endl;
return 0;
}

int C(char *p){
std::cout<<"***"<<p<<"***/n";
return 0;
}

int B(int(*pp)(char *),char *p)
{
pp(p);
return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
char *p = "hello, everyone!";

B(A,p);
B(C,p);
return 0;
}

你可能感兴趣的:(回调函数)