lua 里面的面向对象可以使开发看起来更简洁
local tmp = {}; function tmp:create(id) local obj = { m_id = id, m_name = "guoyilong ", }; setmetatable(obj, {__index = tmp}); return obj; end function tmp:printout() self.m_id = self.m_id * 45; print("===========> self.m_id ",self.m_id); end local tt = tmp:create(45); print("=====> ",tt.m_id); tt:printout();
obj 作为类tmp 的属性
lua进阶7--- 面向对象
时间: 2024-10-21 22:24:35