Skip to Content
Professional Visual Basic 2012 and .NET 4.5 Programming
book

Professional Visual Basic 2012 and .NET 4.5 Programming

by Bill Sheldon, Billy Hollis, Rob Windsor, David McCarter, Gastón Hillar, Todd Herman
January 2013
Intermediate to advanced
912 pages
26h 58m
English
Wrox
Content preview from Professional Visual Basic 2012 and .NET 4.5 Programming

Inheritance

Inheritance is the concept that a new class can be based on an existing class, inheriting the interface and functionality from the original class. In Chapter 3, you explored the relationship between a class and an object, and saw that the class is essentially a template from which objects can be created. Inheritance is always through a single chain to the base Object class. While Visual Basic supports multiple interfaces, it does not support multiple inheritance.

While using objects is very powerful, a single object does not always provide all the capabilities you might like. In particular, in many cases a class only partially describes what you need for your object. You may have a class called Person, for instance, which has all the properties and methods that apply to all types of people, such as first name, last name, and birth date. While useful, this class probably does not have everything you need to describe a specific type of person, such as an employee or a customer. An employee would have a hire date and a salary, which are not included in Person, while a customer would have a credit rating, something neither the Person nor the Employee classes would need.

Without inheritance, you would probably end up replicating the code from the Person class in both the Employee and Customer classes so that they would have that same functionality as well as the ability to add new functionality of their own.

Inheritance makes it very easy to create classes for Employee

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Visual Basic 2012 Programmer's Reference

Visual Basic 2012 Programmer's Reference

Rod Stephens

Publisher Resources

ISBN: 9781118332139Purchase book