Explaining inheritance, overloading, and overriding

Inheritance is a very important characteristic of OOP. It is the relation between two (or more) classes: if class B is some kind of class A, then the objects of class B have the same properties as the objects of class A. In addition to that, class B can implement new methods and properties, and thus supersede the base class A.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

Let's review this example by performing the following steps:

  1. Create a new default console application. Name it InheritanceTest.
  2. Open the InheritanceTest.cpp file and insert the following code:
    #include "stdafx.h" #include <iostream> using namespace std; class CPerson { public: CPerson(int iAge, char* sName) ...

Get C++ Multithreading Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.