lua实现面向对象
- lua实现面向对象
- 实现类的定义
- 实现类的继承
实现类的定义
function people( name)
local self = {}
local function init( ... )
self.name=name
end
self.sayHi=function ( ... )
print("hello"..self.name)
end
init()
return self
end
实现类的继承
function Man( name)
self=people(name)
self.sayHello=function ( )
print("hi"..self.name)
end
return self
end
local ex = Man("李四")
ex.sayHello()
时间: 2024-10-12 10:02:49