O'Reilly logo

Object-Oriented Programming with C++ by A.K. Sharma

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7

INHERITANCE: EXTENDING CLASSES

7.1 INTRODUCTION TO CODE REUSE

Almost all programming languages support functions that allow a piece of code to be reused again and again in a calling program. However, functions provide rather limited support for code reuse. In object-oriented programming (OOP), code reuse is a central feature. In fact, we can reuse the code written in a class in another class by either of the two mechanisms given below:

  1. Containership
  2. Inheritance
7.2 CONTAINERSHIP

In day-to-day life, we come across objects which are composed of other objects. For instance, a computer is composed of objects like motherboard, hard disk, CD-ROM drive, monitor, etc. The motherboard contains a CPU and other components. The CPU contains ALU, CU and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required