The example below explains inheritance, an important property of OOP languages.

We have three classes: living, animal & dog. The dog inherits all the characteristics of living & animal base classes however, the plant does not(being an instance of just the living class).

#include<span style="color: blue; font-size: xx-small;">&lt;</span>iostream<span style="color: blue; font-size: xx-small;">&gt;</span>
using namespace std<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: red;"><strong>class</strong></span> living
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
      <span style="color: red;"><strong>int</strong></span> energy<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
      <span style="color: red;"><strong>public</strong></span><span style="color: blue; font-size: xx-small;">:</span>
                <span style="color: red;"><strong>void</strong></span> getenergy<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
                <span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
                     cout<span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: purple;">"Gets energy"</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span>endl<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
                     <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: red;"><strong>class</strong></span> animal<span style="color: blue; font-size: xx-small;">:</span><span style="color: red;"><strong>public</strong></span> living
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
      <span style="color: red;"><strong>int</strong></span> feet<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
      <span style="color: red;"><strong>public</strong></span><span style="color: blue; font-size: xx-small;">:</span>
                <span style="color: red;"><strong>void</strong></span> move<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
                <span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
                     cout<span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: purple;">"It moves"</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span>endl<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
                     <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: red;"><strong>class</strong></span> dog<span style="color: blue; font-size: xx-small;">:</span><span style="color: red;"><strong>public</strong></span> animal
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>

      <span style="color: red;"><strong>int</strong></span> tail<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
      <span style="color: red;"><strong>public</strong></span><span style="color: blue; font-size: xx-small;">:</span>
                <span style="color: red;"><strong>void</strong></span> bark<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
                <span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
                     cout<span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: purple;">"It barks"</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span>endl<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
                     <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: red;"><strong>int</strong></span> <span style="color: red;"><strong>main</strong></span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
    living plant<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    plant<span style="color: blue; font-size: xx-small;"><strong>.</strong></span>getenergy<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

    dog phoenix<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    phoenix<span style="color: blue; font-size: xx-small;"><strong>.</strong></span>getenergy<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    phoenix<span style="color: blue; font-size: xx-small;"><strong>.</strong></span>move<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    phoenix<span style="color: blue; font-size: xx-small;"><strong>.</strong></span>bark<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

    system<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: purple;">"pause"</span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    <span style="color: red;"><strong>return</strong></span> <span style="color: #a52a2a;">0</span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span>

The dog inherits the properties of animal which inherits the properties of living. Hence, this inheritance is an example of “Multi-level” inheritance.