|
|
||||||||
|
||||||||
|
||||||||
|
|
|
| Visual Basic Tutorials : .NET Tutorials | RSS |
| Visual Basic, created by Microsoft for building stand alone Windows-based programs, is derived heavily from Basic. Developers can use it for quickly building GUI applications. If you're looking for a fast way to build programs, Visual Basic may be just what you need; be sure to check out the tutorials in this section! |
|
| JOIN OUR VISUAL BASIC DISCUSSION FORUM |
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
- By:
- shravan
Mar 21st, 2006 at 12:33 PMImports System.Console Module Module1 Class shan Inherits shan1 Shadows Function fun() As Integer WriteLine(" in derived ") End Function End Class Class shan1 Function fun() As Integer WriteLine(" in base") End Function End Class Sub Main() 'Dim temp As shan1 Dim temp As Object Dim temp1 As New shan Dim temp2 As New shan temp = temp1 temp.fun() temp2 = temp temp2.fun() ReadLine() End Sub End Module see in the vb.net polymorphism is designed in such a manner which is entirely different from other language . well i am in learning phase so please do correct me if i get wrong somewhere here in the code if i make a object class reference and put a instance of a class shan and then call the function fun() then it is calling that function which it should not call since there is no function fun() defined in the object class so it should give error such as "no such member in the object class" but rather its calling . now the interesting thing is if u do the same thing by using the base and derived class (shown in the code ) then it will give the error ( what i stated above) and it is working fine. so why it is behaving differently for the object class. one more thing i want to express temp = temp1 temp.fun() temp2 = temp it should not work or should give warning or should demand explict conversion but it is converting simply without any problem ??