VISUAL BASIC (2 Edition), For Beginners, Learn Coding Fast (With 100 Tests & Answers) Crash Course, Quick Start Guide, Tutorial Book with Hands-On Projects in Easy Steps! An Ultimate Beginners Guide! by Ray Yao

VISUAL BASIC (2 Edition), For Beginners, Learn Coding Fast (With 100 Tests & Answers) Crash Course, Quick Start Guide, Tutorial Book with Hands-On Projects in Easy Steps! An Ultimate Beginners Guide! by Ray Yao

Author:Ray Yao
Language: eng
Format: azw3
Publisher: Rails Excel Sharepoint Angularjs Access Lamp Actionscript VBA Photoshop Illustrator ColdFusion Teach Yourself
Published: 2017-07-28T07:00:00+00:00


Example 6.8

Module Module1

Public Class Computer 'declare a base class

Public Function display()

Console.WriteLine("Computer OK")

Console.ReadLine()

End Function

End Class

Public Class Laptop

Inherits Computer ‘declare a derived class

'drived class’s members in here

End Class

Sub Main()

Dim Lt As Laptop

Lt = New Laptop() 'derived class creates an object Lt

Lt.display() 'Lt calls base class's method

End Sub

End Module

Output:

Computer OK!

Explanation:

“Inherits” is a keyword of inheritance.

“Inherits” should appear in new line.

“Lt. display( )” means a derived class object “Lt” calls base class’s method display( ), because an object of derived class can access the public member of base class.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.