title: C++ Generic List Assignment
body: <p>I've clearly been stuck in Java land for too long... Is it possible to do the C++ equivalent of the following Java code:</p>
  
  <pre><code>interface Foo {}
  
  class Bar implements Foo {}
  
  static List&lt;Foo&gt; getFoo() {
    return new LinkedList&lt;Foo&gt;();
  }
  
  static List&lt;Bar&gt; getBar() {
    return new LinkedList&lt;Bar&gt;();
  }
  
  List&lt;? extends Foo&gt; stuff = getBar();
  </code></pre>
  
  <p>Where Foo is a sub-class of Bar.</p>
  
  <p>So in C++....</p>
  
  <pre><code>std::list&lt;Bar&gt; * getBars()
  {
    std::list&lt;Bar&gt; * bars = new std::list&lt;Bar&gt;;
    return bars;
  }
  
  std::list&lt;Foo&gt; * stuff = getBars();
  </code></pre>
  
  <p>Hope that makes sense....</p>