by John
Kopp
Introduction Welcome to About.com's
free tutorial on C++ programming. This lesson covers basic inheritance.
Classes in object-oriented programming attempt to model real
world entities. Just as an entity has properties and
abilities, a class has data members
and methods.
Both entities in the real world, and classes
in the worlds our programs create have various relationships.
These relationships help to simplify the task of understanding
the systems we create and the entities of which they are
constructed.
One such relationship is inheritance. In C++, inheritance
defines an "is a" relationship. The derived
class is a type of its base class. For instance, a "cat"
class could be derived from an "animal" class. A cat is an
animal. A cat is a type of animal. A derived class inherits
both the data members and methods of its base class. It may
also define additional members and methods that support
specialized functionality. All of this is best understood by
studying some simple examples. Next
page > Inheritance
> Page 1,
2,
3,
4,
5
|