LOTUSSCRIPT LANGUAGE
The syntax is:
[ Public | Private ] Class className As baseClass
Class MyClass1 ' Base class. a As Integer Public c As Integer '... End Class Class MyClass2 As MyClass1 ' Class derived from MyClass1. b As Integer Public d As Integer '... End Class Dim x As New MyClass2 ' Object x has members ' a%, b%, c%, and d%. x.c% = 12 x.d% = 35 '...
Usually you use a derived class when an existing class provides members that the new class can use, or when you want to extend or embellish existing class properties and methods. This is called inheritance: the new class inherits, and has direct access to, all Public and Private members of the existing base class.
For example, you want to create derived classes called CheckingAccount, SavingsAccount, BrokerageAccount, and RetirementAccount based on an existing Account class. Because the derived classes can access all existing properties and methods for the Account class, such as AccountNumber, Balance, and DepositMoney, you can reuse all Account class scripts in the new classes.
You can define new member variables, properties, and methods in a derived class to add operations that the derived classes can use. For example, you can add BuyStock and SellStock methods to the BrokerageAccount class.
A derived class can serve as the base class for another derived class. For example, the following illustration shows how the Contractor class, which is derived from the Employee class, serves as the base class for the Subcontractor class. The Subcontractor class has access to the members of both the Contractor class and the Employee class.
A derived class has the same scope as its base class, except that a derived class cannot access the Sub Delete of its base class.
See Also