12345678910111213141516171819Object = {}-- 构造方法function Object:new() local o = {} self.__index = self setmetatable(o,self) return oend-- 继承function Object:SubClass(className) _G[className] = {} self.__index = self _G[className].base = self -- 实现重写调用父类的方法 setmetatable(_G[className],self)end 重写并调用父类方法1234567891011121314function Object:Hello() print("obj hello")endObject:SubClass("Cat")local c = Cat:new()function Cat:Hello() self.base.Hello() -- 调用 . print("cat hello")endc:Hello()