function a:ctor()
self.a = 1
self:func()
end
function a:func()
self.b = self.a
end
b继承了a
function b:ctor()
b.super.ctor(self)
end
function b:func()
b.super:func()
self.c = self.a
end
这么写有什么问题?
就是b重写了a的构造函数中调用的一个函数。
提示在b创建的时候,好像self是nil。
function a:ctor()
self.a = 1
self:func()
end
function a:func()
self.b = self.a
end
b继承了a
function b:ctor()
b.super.ctor(self)
end
function b:func()
b.super:func()
self.c = self.a
end
这么写有什么问题?
就是b重写了a的构造函数中调用的一个函数。
提示在b创建的时候,好像self是nil。
b.super:func()
要写成
b.super.func(self)