demand. For this purpose, the Base Class Library

Debug.Writeline(”Sec before: ” & CStr(MySecretary.Salary)) MySecretary.IncSalary(0.3) Debug.Writeline(”Sec after: ” & CStr(MySecretary.Salary)) The output in this case is: Pres before: 1000000 Pres after: 1450000 Sec before: 30000 Sec after: 39600 The notion of inheritance is quite simple, as put forth in Microsoft’s documentation: If Class B inherits from Class A, then any object of Class B is also an object of Class A and so includes the public properties and methods (that is, the public interface) of Class A. In this case, Class A is called the base class and Class B is called the derived class. On the other hand, in general, the derived class can override the implementation of a member of the base class for its own use. We have seen in the previous example that inheritance is implemented using the Inherits keyword. 3.4.1 Permission to Inherit There are two keywords used in the base class definition that affect the ability to inherit from a base class: NotInheritable When this is used to define a class, as in: Public NotInheritable Class InterfaceExample the class cannot be used as a base class. MustInherit When this is used to define a class, as in: Public MustInherit Class InterfaceExample objects of this class cannot be created directly. Objects of a derived class can be created, however. In other words, MustInherit classes can be used as base classes and only as base classes. 3.4.2 Overriding There are several keywords that control whether a derived class can override an implementation in the base class. These keywords are used in the declaration of the member in question, rather than in the class definition: Overridable Allows but does not require a member to be overridden. Note that the default for a Public member is NotOverridable. Here is an example: Public Overridable Sub IncSalary( )

Hint: If you are looking for very good and affordable webspace to host and run your j2ee hosting application check Virtualwebstudio j2ee web hosting services

Comments are closed.