clsObject = {
__ClassType = "class type"
}
function clsObject:Inherit(o)
o = o or {}
o.__ClassType = "class type"
o.mt = { __index = o}
setmetatable(o, {__index = self})
return o
end
function clsObject:New(...)
local o = {}
setmetatable(o, self.mt)
if o.__init__ then
o:__init__(...)
end
return o
end
function clsObject:__init__()
end
function clsObject:Destroy()
end
function clsObject:GetType()
return "BaseClass"
end
function Super(TmpClass)
return getmetatable(TmpClass).__index
end
function IsSub(clsSub, clsAncestor)
local Temp = clsSub
while 1 do
local mt = getmetatable(Temp)
if mt then
Temp = mt.__index
if Temp == clsAncestor then
return true
end
else
return false
end
end
end
clsParent = clsObject:Inherit()
function clsParent:Foo()
print("ParentFoo!")
end
local ParentObj = clsParent:New()
ParentObj:Foo()
clsSon = clsParent:Inherit()
function clsSon:Foo()
Super(clsSon).Foo(self)
print("SonFoo")
end
local SonObj = clsSon:Inherit()
SonObj:Foo()
print(IsSub(clsSon, clsParent))
print(IsSub(clsSon, clsObject))
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有