Changing behaviour of parent virtual function based on inherited type parameter
<p>I have an inheritance hierarchy with a base class and two derived classes.</p>

<p>In the base class, I have a virtual function:</p>

<pre><code>virtual void interact(const Base &amp;other) const;
</code></pre>

<p>In the derived classes, they both have the following two functions, which are necessary as the two derived classes interact different with each other (i.e. <code>Derived1</code> and <code>Derived1</code> interact differently than <code>Derived1</code> and <code>Derived2</code>) :</p>

<pre><code>void interact(const Derived1 &amp;other) const;
void interact(const Derived2 &amp;other) const;
</code></pre>

<p>I want to be able to take two objects from a <code>vector&lt;Base&gt;</code> and call the virtual <code>Base</code> class method (e.g. <code>base1.interact(base2)</code>) and have the correct function in the derived classes to be called based on the derived types.</p>

<p>Is there a way I can do this, or is my approach wrong entirely?</p>