title: Is it possible to pass derived classes by reference to a function taking base class as a parameter
body: <p>Say we have an abstract base class <code>IBase</code> with pure virtual methods (an interface).</p>
  
  <p>Then we derive <code>CFoo</code>, <code>CFoo2</code> from the base class.</p>
  
  <p>And we have a function that knows how to work with IBase.</p>
  
  <pre><code>Foo(IBase *input);
  </code></pre>
  
  <p>The usual scenario in these cases is like this:</p>
  
  <pre><code>IBase *ptr = static_cast&lt;IBase*&gt;(new CFoo("abc"));
  Foo(ptr);
  delete ptr;
  </code></pre>
  
  <p>But pointer management is better to be avoided, so is there a way to use references in such scenario?</p>
  
  <pre><code>CFoo inst("abc");
  Foo(inst);
  </code></pre>
  
  <p>where <code>Foo</code> is:</p>
  
  <pre><code>Foo(IBase &amp;input);
  </code></pre>