-- base class
Window = {
x = 0,
y = 0,
height = 0,
width = 0,
display = function(self)
print('Window', x, y, height, width)
end
}
-- structure function
function Window:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self;
return o
end
-- extend
function Window:extend()
o = {}
setmetatable(o, self)
self.__index = self;
return o
end
-- MyWindow
MyWindow = Window:extend()
-- override
function MyWindow:display()
print('MyWindow', self.x, self.y, self.height, self.width)
end
-- new MyWindow
s = MyWindow:new{x=1,y=1,height=800,width=600}
s:display()
|