![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
面向对象
wanjun_j
学习记录
展开
-
Lua 实现面向对象 进阶
class方法 function class(className, super, ...) local cla = {} if super and type(super) == "table" then for i,v in pairs(super) do cla[i] = v cla.super = super end else cla = {ctor = function()end}原创 2020-07-13 03:04:00 · 174 阅读 · 0 评论 -
Lua 实现面向对象 踩坑
基类 local a = {} function a:new(name) local a_n = {} setmetatable(a_n, self) self.__index = self self.name = name print("a-----new ", "'a-address'---- ", a, "'a_n-address'---- ", a_n) print("a_n getmetatable ",getmetatable(a_n)原创 2020-07-13 02:45:51 · 202 阅读 · 0 评论 -
Lua 实现面向对象
创建对象 local a = {} function a:new(param) local n = {} setmetatable(n, self) self.__index = self self.name = param.name self.value = param.value return n end function a:printValue() print("a----- ", self.value) end function原创 2020-07-13 01:44:55 · 267 阅读 · 0 评论