title: C++ Inheritance with parent "knowing" the children
body: <p>Hello I have a global array of let's say </p>
  
  <pre><code>array = ["A", "B", "C", "D", "E"]
  </code></pre>
  
  <p>I want to design a parent class with 5 children classes like this</p>
  
  <pre><code>Parent, Child1, Child2, Child3, Child4, Child5
  </code></pre>
  
  <p>The Parent class will have a method name getID();</p>
  
  <p>How can i design such that this behavior occur</p>
  
  <pre><code>Child1.getID() is array[0] gives "A"
  Child2.getID() is array[1] gives "B"
  Child3.getID() is array[2] gives "C"
  Child4.getID() is array[3] gives "D"
  Child5.getID() is array[4] gives "E"
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>The reason is that I don't want to keep copy and pasting getID() for 5 children. It would be nice to just write getID() in parent class.</p>