[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua objects and inheritance
- From: "Michael Cumming" <Mike.C@...>
- Date: Thu, 14 Apr 2005 07:19:01 -0500
I have been following the examples in the book and have a
question about inheritance. I can see how it works for a single
parent/child but what about parent/child1/child2?
parent = {
New = function (self,o)
o = o or {}
setmetatable (o,self)
self.__index = self
end,
Quit = function
(self)
end
}
child1 = {
New = function (self,o)
o =
parent:New (o or {})
setmetatable
(o,self)
self.__index = self
end,
Quit = function
(self)
parent.Quit
(self)
end
}
child2 = {
New = function (self,o)
o =
child1:New (o or {})
setmetatable
(o,self)
self.__index = self
end,
Quit = function
(self)
child1.Quit
(self)
end
}