How to thoroughly understand the callback function through Lua
This article is about how to thoroughly understand the callback function through Lua, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Lua callback function instance local m = {} local list = {name= "hello", age=12} m.call_back_fun_print = function (printID) print (printID. "-->".. List [printID]) endm.add_list = function (key,value,call_back_fun) key = tostring (key) list [key] = value call_back_fun (key) endm.add_list ("address", "beijing", m.call_back_fun_print)-address-- > beijingreturn mC++ callback function instance # include # include using namespace std;typedef void (* Fun) (int,int,int) / / define the function pointer type void call_back_fun_print (int a _ line int b _ int _ int min) {cout