Inheritance
In the pure world of OOP, objects can be created from other objects. Any properties and methods from one class are then automatically available as properties and methods of the new class. This is called Inheritance.
Visual Basic provides a modified version of Inheritance commonly termed Containment. A class can still expose its childrens' properties and methods but the developer of the class must explicitly reference the child in any calls made to those properties or methods. A comparison is the best way of explaining this concept.
Figure 1. C++ directly uses Person.Name when Student.Name is calledFigure 2. VB must explicitly call Person.Name when Student.Name is calledLet's look at how you would code this :
'Class : clsStudent Public Property Let Name ( sNewName as String) |
No comments:
Post a Comment