Chapter 8: Inheritance

Download CD Content


In this chapter, you will learn how to:

  • Describe the importance of inheritance in object-oriented programming

  • Define a base class

  • Define a derived class

  • Access base-class members from the derived class

  • Use the virtual keyword to achieve polymorphism

  • Define abstract classes and abstract methods

  • Define sealed classes

  • Use interfaces

Inheritance is an important object-oriented concept. Inheritance enables you to define a common base class that captures the similarities between several different classes. The base class contains the common data members and member functions for all these other classes.

You can then define derived classes that inherit all these members, and add new data members and member functions as required. Derived classes can also override some of the methods defined in the base class. This is known as polymorphism, and it is an extremely useful programming technique.

The benefits of inheritance are well documented in the object-oriented community. Inheritance helps you develop applications more quickly because you can reuse functionality defined in the base class. Testing and maintenance are simplified because there is less code in your application. Inheritance also helps you create a more accurate and meaningful model of your system.

In this chapter, you will learn how to use all aspects of inheritance in Microsoft Visual C++. You will see how to define base classes and derived classes, and you will find out how to use these classes effectively in your application.

Microsoft Visual C++  .NET(c) Step by Step
Microsoft Visual C++ .NET(c) Step by Step
ISBN: 735615675
Year: 2003
Pages: 208 © 2008-2017.
If you may any questions please contact us: