R
Rexel
Lets see if I have got this correct.
I have a class A which has a method: Compute.
I create a new class B which inherits from A.
Class B now has all the methods of class A.
If in the code I use:
Dim b AS New B
b.Compute()
this causes the code in A.Compute to execute. Right?
Now I add a method to B which is also named Compute,
but in Class B I use the keyword Override when creating
the method.
If I again use the same code,i.e.,
Dim b AS New B
b.Compute()
this time the code in B.Compute will run and the code
in A.Compute is skipped.
Is this correct?
What if I don't use the keyword Override for Compute method
in Class B?
What happens now when I call b.Compute?
Which method is run? B.Compute, A.Compute, or both?
My confusion on this subject is because when you create
a form it has a New method, thus:
Private Sub New()
MyBase.New()
'
End Sub
So the base from which this form was derived also has a
method called New.
Why isn't Override used here?
I have a class A which has a method: Compute.
I create a new class B which inherits from A.
Class B now has all the methods of class A.
If in the code I use:
Dim b AS New B
b.Compute()
this causes the code in A.Compute to execute. Right?
Now I add a method to B which is also named Compute,
but in Class B I use the keyword Override when creating
the method.
If I again use the same code,i.e.,
Dim b AS New B
b.Compute()
this time the code in B.Compute will run and the code
in A.Compute is skipped.
Is this correct?
What if I don't use the keyword Override for Compute method
in Class B?
What happens now when I call b.Compute?
Which method is run? B.Compute, A.Compute, or both?
My confusion on this subject is because when you create
a form it has a New method, thus:
Private Sub New()
MyBase.New()
'
End Sub
So the base from which this form was derived also has a
method called New.
Why isn't Override used here?