#include <iostream> //functional template<typename Arg1,typename Ret> class unary_function{ public: typedef Arg1 argument_type; typedef Ret result_type; }; template<typename Arg1,typename Arg2,typename Ret> class binary_function{ public: typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Ret result_type; }; template<typename Arg1,typename Arg2,typename Ret> class pointer_to_binary_function:public binary_function<Arg1,Arg2,Ret>{ public: explicit pointer_to_binary_function(Ret (_cdecl*pf_)(Arg1,Arg2)) :pf(pf_){} Ret operator()(Arg1 left,Arg2 right){ return (pf(left,right)); } private : Ret (_cdecl*pf)(Arg1,Arg2); }; template<typename Arg1,typename Arg2,typename Ret> pointer_to_binary_function<Arg1,Arg2,Ret> ptr_fun(Ret (_cdecl*pf)(Arg1,Arg2)){ return pointer_to_binary_function<Arg1,Arg2,Ret>(pf); } //test void Print(int a,int b){ std::cout<<"Arg1 is "<<a<<std::endl; std::cout<<"Arg2 is "<<b<<std::endl; } int main(int argc,char* argv[]){ int a=3; int b=30; Print(a,b); (pointer_to_binary_function<int,int,void>(Print))(a,b); ptr_fun(Print)(a,b); return 0; }