Chapter 9. Class Inheritance and Virtual Functions
In this chapter, you're going to look into a topic that lies at the heart of object-oriented programming: class inheritance. Simply put, inheritance is the means by which you can define a new class in terms of one you already have. This is fundamental to programming in C++ so it's important that you understand how inheritance works.
In this chapter, you will learn about:
How inheritance fits into the idea of object-oriented programming
Defining a new class in terms of an existing one
The use of the
protected
keyword to define a new access specification for class membersHow a class can be a friend to another class
Virtual functions and how you can use them
Pure virtual functions
Abstract classes
Virtual destructors and when to use them
Basic Ideas of OOP
As you have seen, a class is a data type that you define to suit your own application requirements. Classes in object-oriented programming also define the objects to which your program relates. You program the solution to a problem in terms of the objects that are specific to the problem, using operations that work directly with those objects. You can define a class to represent something abstract, such as a complex number, which is a mathematical concept, or a truck, which is decidedly physical (especially if you run into one on the highway). So, as well as being a data type, a class can also be a definition of a set of real-world objects of a particular kind, at least to the degree necessary ...
Get Ivor Horton's Beginning Visual C++®2008 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.