1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
// callback.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
template <typename R, typename A1, typename A2> struct T_Funct;
template <typename R, typename A1, typename A2> struct T_Funct<R (__stdcall *)(A1,A2), A1, A2>{
typedef R (Run)(A1,A2);
R (__stdcall *function_)(A1, A2);
explicit T_Funct(R(__stdcall *function)(A1,A2), A1 a1, A2 a2):function_(function),a1_(a1),a2_(a2){}
R operator()(){
return function_();
}
};
int show_int(int , int ){
return printf("print_int is invoked...\n");
}
int _tmain(int argc, _TCHAR* argv[])
{
typedef int (*p_fun_int)(int, int );
p_fun_int fun_int;
fun_int = show_int;
T_Funct<int , int , int > t_funct(fun_int, 1,2);
return 0;
}
| |