Section 25.7. Notes on Generics and Inheritance


25.7. Notes on Generics and Inheritance

Generics can be used with inheritance in several ways:

  • A generic class can be derived from a non-generic class. For example, class Object (which is not a generic class) is a direct or indirect base class of every generic class.

  • A generic class can be derived from another generic class. Recall that in Chapter 24, the non-generic Stack class (Fig. 24.13) inherits from the non-generic List class (Fig. 24.6). You could also create a generic Stack class by inheriting from a generic List class.

  • A non-generic class can be derived from a generic class with a specific type argument. Forexample, you can implement a non-generic AddressList class which inherits from a generic List class that stores Address objects.



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

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