Chapter 10. Object-Oriented Programming: Inheritance


Say not you know another entirely, till you have divided an inheritance with him.

Johann Kasper Lavater

This method is to define as the number of a class the class of all classes similar to the given class.

Bertrand Russell

Good as it is to inherit a library, it is better to collect one.

Augustine Birrell

Save base authority from others' books.

William Shakespeare

Objectives

In this chapter you will learn:

  • What inheritance is and how it promotes software reusability.

  • The notions of base classes and derived classes.

  • To use keyword Inherits to create a class that inherits attributes and behaviors from another class.

  • To use the access modifier Protected in a base class to give derived class methods access to base class members.

  • To access base class members from a derived class with MyBase.

  • How constructors are used in inheritance hierarchies.

  • To access the current object with Me and MyClass.

  • The methods of class Objectthe direct or indirect base class of all classes in Visual Basic.

Outline

10.1 Introduction

10.2 Base Classes and Derived Classes

10.3 Protected Members

10.4 Relationship between Base Classes and Derived Classes

10.4.1 Creating and Using a CommissionEmployee Class

10.4.2 Creating a BasePlusCommissionEmployee Class without Using Inheritance

10.4.3 Creating a CommissionEmployeeBasePlusCommissionEmployee Inheritance Hierarchy

10.4.4 CommissionEmployeeBasePlusCommissionEmployee Inheritance Hierarchy Using Protected Instance Variables

10.4.5 CommissionEmployeeBasePlusCommissionEmployee Inheritance Hierarchy Using Private Instance Variables

10.5 Constructors in Derived Classes

10.6 Software Engineering with Inheritance

10.7 Class Object

10.8 Friend Members

10.9 Wrap-Up



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