title: Parent object call Child method C++
body: <p>I have somes difficults with inheritance in C++. Suppose I have a class base Parent: </p>
  
  <pre><code>class Parent{
  public:
        ...
        virtual Parent Intersection(Parent anotherParent);
  
  }
  </code></pre>
  
  <p>and 2 classes children Numeric and Symbolic with implement of method Intersection:</p>
  
  <pre><code>class Numeric : public Parent{
  public:
        ...
        Numeric Intersection(Numeric anotherNumeric)
        {
         ...
        }; // do intersection with another object numeric
  
  }
  
  // class Symbolic
  class Symbolic : public Parent{
  public:
        ...
        symbolic Intersection(Symbolic anotherSymbolic)
        {
         ...
        }; // do intersection with another object symbolic
  
  }
  </code></pre>
  
  <p>and a last class ParentVector:</p>
  
  <pre><code>class ParentVector : public Parent{
  public:
        ...
        ParentVector Intersection(ParentVector anotherParentVector);
  
  private:
        std::vector&lt;Parent&gt; vtParent; // vector stock object Parent (Numeric or Symbolic)
  
  }
  </code></pre>
  
  <p>I want vector vtParent stock 2 types of object: Numeric or Symbolic. So I created a vector of Parent objects.</p>
  
  <p>The problem is: I want get Intersection of 2 vectors ParentVector. </p>
  
  <p>I can add an object Numeric or Symbolic in vector vtParent but I <strong>can not</strong> call the method Intersection correspond each type of object. It always call method Intersection of class Parent.</p>
  
  <p>Anyone have some ideas or suggestions ? Many thanks.</p>
  
  <p>//edit : I forgot that the class ParentVector is a child of Parent class, too.</p>
  
  <p>// UPDATE: thanks for all your useful helps. Now, I want to execute the code below to calculate the Intersection of 2 vectors Parent :</p>
  
  <pre><code>ParentVector* Intersection(ParentVector anotherParentVector){
       ParentVector* result;
       Parent* tmp;
  
       for( int i = 0; i &lt; this-&gt;vtParent.size(i); i++ ){
             // PROBLEM with this line because I don't write the code of 
             // function 'virtual Parent* Parent::Intersection(Parent anotherParent)'
  
            *tmp = this-&gt;vtParent.at(i)-&gt;Intersection(anotherParentVector.getParentVector().at(i));
            result-&gt;getParentVector.push_back(tmp);
       }
  }
  </code></pre>
  
  <p>I don't write the code of function 'virtual Parent* Parent::Intersection(Parent anotherParent)', so I can not execute the code above. Some one has an idea how to resolve this problem ?</p>
  
  <p>// Here, the idea is I want to call function 'Numeric* Intersection(Numeric anotherNumeric)' or 'Symbolic* Intersection(Symbolic anotherSymbolic)'</p>
  
  <p>// FINISH, thanks for all yours suggestion.</p>