Quote:
quote:Originally posted by planoie
...What you are showing is:
1) We have interface 'IMyItf' (with 'int Func(int i,int j)')
2) Class 'Base1' implements 'IMyItf.Func()'
3) 'Derived' inherits from Base1
4) 'Derived' reimplements the method 'Func()'.
Is the intent of 'Derived.Func' to override 'Base1.Func'?...
Here's what I tried in VB:
Imports System
Public Interface IMyItf
Sub MyMethod()
End Interface
Public Class Base1
Implements IMyItf
Public Overridable Sub MyMethod() Implements IMyItf.MyMethod
Console.WriteLine("Base1.MyMethod")
End Sub
End Class
Public Class Derived : Inherits Base1
Public Overrides Sub MyMethod()
Console.WriteLine("Derived.MyMethod")
End Sub
End Class
|
Class 'Base1' implements 'IMyItf.Func()' expilictly(privately) therefore you cant use polymorphism in your
VB.NET code because it is a private function,so you have to re-implement the interface in Derived
class but in
VB.NET you cant,
Quote:
quote:Originally posted by mehdi62b
...mainly VB.NET doesnt let us reimplement interfaces in subclasses,maybe you notice me why your example implements the interface in Base class explicitly,the answer is sometimes maybe we want to use some classes in .NET framework and we should extend them,but some interfaces have been implemented explicitly(private) so we have to implement them in Derived class,but as I mentioned VB.NET compiler throws an error:
Interface 'IMyItf' is already implemented by base class 'Base1'.
(for example take a look at this link,http://weblogs.asp.net/fbouma/archiv.../12/37199.aspx)...
|
sometimes you may need to implement some procedures of an interface in your base class privately,so if you want to derive
another class and use those private procedures,you should re-implement your interface in your derived class,
but in
VB.NET(1.1) you cant.
_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.