|
June 6, 2002 Deriving a Specialized Class from a Generic Class Tips: June 2002
Yehuda Shiran, Ph.D.
|
|
You usually use inheritance to derive
a specialized class from a generic, base class. As an example, think of the manager
and employee in a company. Every manager in a company is also its employee. It
makes sense to define an employee base class, and extend it to a manager class.
Here is the Employee
class:
Let's now extend the Employee class to the Manager class:
We construct an instance of the Manager class as follows:
We can print the salary and mailing label now:
The output should be as follows:
To learn more about JScript .NET, go to Column 110, JScript .NET, Part IV: Inheritance.
People who read this tip also read these tips: Look for similar tips by subject: |