标签:style blog io ar os sp strong on div
local m = {} local list = {name="hello",age=12} m.call_back_fun_print = function(printID) print(printID .. "-->" .. list[printID]) end m.add_list = function(key,value,call_back_fun) key = tostring(key) list[key] = value call_back_fun(key) end m.add_list("address","beijing",m.call_back_fun_print) --address-->beijing return m
#include <stdlib.h> #include <iostream> using namespace std; typedef void(*Fun)(int,int,int); //定义函数指针类型 void call_back_fun_print(int a,int b,int min) { cout<<"compare "<<a<<" and " <<b<<" ,min= "<<min<<endl; } void min(int a,int b,Fun call_back_fun) { int minvalue=a<b?a:b; call_back_fun(a,b,minvalue); } int main() { min(12,14,call_back_fun_print);//-->compare 12 and 14 ,min= 12 return 0; }
标签:style blog io ar os sp strong on div
原文地址:http://blog.csdn.net/shimazhuge/article/details/41680909