level 3
请问下,lua 这样写 类 可以吗?
function createobj( name )
local obj = {}
function obj.syeHello()
print( "hello" )
end
return obj
end
local obj = createobj( "123" )
obj.sayHello()
2014年10月13日 04点10分
1
level 8
student={}
student.name=nil
studnet.age=nil
function student.new(this,name,age)
this.name=name
this.age=age
end
funciton student.say(this)
io.wirte("I*m ",this.name,this.age)
end
s=student
s.new(s,"zhangsan",25)
s.say(s)
2014年10月15日 08点10分
5