Simple Inheritance

How does inheritance solve the issues you had with your Employee and Customer classes? Well, you can apply the generalization process and move from particular to general. In your example you noticed that three of the properties are common to both classes. That means that you could have a base class named Person, for example, in which you place the common properties. Then you inherit from this class both your Employee and Customer classes. In this way you solve both issues (code reuse and common behavior). Let's see how this is done. First you write the base class:

 Public Class Person Private m_name As String Private m_dob As Date Private m_email As String Public Property name() As String Get Return m_name End Get Set m_name ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.