18.17. Abstract Classes


Every subclass of Window should implement its own DrawWindow method but nothing requires that it do so. To require subclasses to implement a method of their base, you need to designate that method as abstract .

An abstract method has no implementation. An abstract method creates a method name and signature that must be implemented in all derived classes. Furthermore, making one or more methods of any class abstract has the side effect of making the entire class abstract.

Abstract classes establish a base for derived classes, but it is not legal to instantiate an object of an abstract class. Once you declare a method to be abstract, you prohibit the creation of any instances of that class.

18.17.1. NotInheritable Class

The opposite side of the design coin from abstract is NotInheritable. Although an abstract class is intended to be derived-from and to provide a template for its subclasses to follow, a NotInheritable class does not allow classes to derive from it at all. The NotInheritable keyword placed before the class declaration precludes derivation. Classes are most often marked NotInheritable to prevent accidental inheritance.



Programming Visual Basic 2005
Programming Visual Basic 2005
ISBN: 0596009496
EAN: 2147483647
Year: 2006
Pages: 162
Authors: Jesse Liberty

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