Hi, I would like to know how to call a proc in Base class in a derived class ?
For the sake of clarity, i have included some VB.NET code. this is my
intention. See this.
Public Class Animal() '// A Base class
Public Weight_of_Animal As Integer
Private Overridable Sub Cry() '// This proc can be call from
derived class
Console.WriteLine("Animal is crying...")
End Sub
Public Sub New() '// Base constructor
Weight_of_Animal = 0
End Sub
End Class
Public Class Dog() : Inherits Animal '// A child class Which derived
from base class.
Public Name As String
Public Sub New(Byval sName As String = "") '// Child class
constructor.
Name = sName
End Sub
Public Overrides Sub Cry() '// Here we are overriding a base class
method
MyBase.Cry()
Console.WriteLine("But Dog is barking...")
End Sub
End Class
'// Usage
Dim myAnimal As Dog = New Dog() '// I have init a dog class.
myAnimal.Cry() '// called the derived class method.
'// Output
Animal is crying...
But Dog is barking...
Run
Please show me how to do this in nim ?