local function class(name, parent)
local tempClass = {}
parent = parent and parent or {}
--实现元方法
parent.__index = function(table, key)
return parent[key]
end
setmetatable(tempClass, parent)
tempClass.__name = name
tempClass.__super = parent
return tempClass
end
local function dump(value, dumpChild)
for k, v in pairs(value) do
local t = type(v)
if t == "function" then
print(k..":function")
elseif t == "table" then
print(k..":table")
if dumpChild then
print("{")
dump(v)
print("}")
end
else
print(k..":"..v)
end
end
end
local classParent = class("parent", nil)
function classParent:ParentFunction()
print("This is ParentFunction")
end
local classChild = class("Child", classParent)
--实现Override
function classChild:ParentFunction()
self.__super:ParentFunction()
print("This is ChildFunction")
end
classChild:ParentFunction()local function class(name, parent)
local