People={
Age=0,
Name=""
}
function People:new(age,name)
local o={}
setmetatable(o,self)
self._index=self
self.Age=age
self.Name=name
return o
end
--.代表静态方法 :代表实例方法
function People:SayHello()
print("MyName is "..self.Name)
end
p1=People:new(12,"asdasd")
p1:SayHello()
应该是self为空,你把
function People:SayHello()
print("MyName is "..self.Name)
end
这个里面的self.Name去掉,看下还报错吗