Class Refinement


Classes can be refined through inheritance, which is code reuse. The common members of related classes can be extracted and placed in a base class. Child classes inherit and refine a base class. A personnel application might have SalariedEmployee, HourlyEmployee, and CommissionedEmployee classes that inherit the Employee class. The Employee class holds the common members of all Employee-derived classes. Each derived class adds members to refine the base class. Optionally, derived classes can override members of the base class. Sealed classes cannot be inherited. Inheritance and polymorphism are closely related. Polymorphism calls the correct method at run time from a base reference to a derived object, and it can add considerable efficiencies to an application.

Inheritance and polymorphism and other strategies to refine class usage are reviewed in Chapter 3.




Programming Microsoft Visual C# 2005(c) The Language
Microsoft Visual Basic 2005 BASICS
ISBN: 0619267208
EAN: 2147483647
Year: 2007
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net