local A = {}
A.__index = A
function A:new(o)
o = o or {}
setmetatable(o,A);
return o
end
function A:test()
print("test A")
end
local B = {}
setmetatable(B,A)
B.__index = B
function B:new(o)
local self = A:new(o)
setmetatable(self,B);
return self
end
-- 重写父类
--function B:test()
-- print("test B")
--end
local a = A:new()
a:test()
local b = B:new()
b:test()
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交