在这个问题上展开一点VBA 继承模式
我在 VBA 中重现了一个基本的继承模式,但我想了解是否有更有效和更简洁的方法来实现这一点。
考虑这个小测试用例。
IAnimal.cls
'declaration
Public Sub eat()
End Sub
Public Sub breathe()
End Sub
Run Code Online (Sandbox Code Playgroud)
Animal.cls :超类
Implements IAnimal
' method implementation
Private Sub IAnimal_eat()
Debug.Print "I'm eating something..."
End Sub
Private Sub IAnimal_breathe()
Debug.Print "I'm brething..."
End Sub
Run Code Online (Sandbox Code Playgroud)
Cat.cls :Animal 的一个子类
Private super As IAnimal
Implements IAnimal
Private Sub Class_Initialize()
Set super = New Animal
End Sub
'#------------------------------------------------
' methods called when object is accessed as an IAnimal implementor.
' I HAVE TO re-implement all …Run Code Online (Sandbox Code Playgroud)