lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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
 
}