title: Pass abstract class(all virtual, so interface) into another class's constructor with default value
body: <p>I've found a few questions on Stackoverflow regarding passing in abstract classes to methods, e.g. <a href="https://stackoverflow.com/questions/20434948/pass-abstract-parameter-to-method-why-not">Pass abstract parameter to method, why not?</a></p>
  
  <p>I want to try and do something like below, but I keep getting an error. I've tried various guesswork like switching to pointers, etc. But nothing really works. I also added <code>: c_()</code> after <code>Other</code>, but that didn't work either. I'm new to the language and am still figuring out how things come together.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Child
  {
  public:
          virtual void Test() = 0;
  };
  
  class Child1 : public Child
  {
  public:
          void Test()
          {
                  std::cout &lt;&lt; "Child1" &lt;&lt; std::endl;
          }
  };
  
  class Child2 : public Child
  {
  public:
          void Test()
          {
                  std::cout &lt;&lt; "Child2" &lt;&lt; std::endl;
          }
  };
  
  class Other
  {
  Child &amp;c_;
  public:
          Other(Child &amp;c=Child2())
          {
                  c_ = c;
          }
          void which_child()
          {
                  c_.Test();
          }
  };
  
  int main()
  {
          Child1 c1;
          Other o(c1);
          o.which_child();
          return 0;
  }
  </code></pre>
  
  <p>Error I'm getting:</p>
  
  <pre><code>test.cpp:31:22: error: non-const lvalue reference to type 'Child' cannot bind to a temporary of type 'Child2'
          Other(Child &amp;c=Child2())
                       ^ ~~~~~~~~
  test.cpp:31:22: note: passing argument to parameter 'c' here
  test.cpp:31:9: error: constructor for 'Other' must explicitly initialize the reference member 'c_'
          Other(Child &amp;c=Child2())
          ^
  test.cpp:29:8: note: declared here
  Child &amp;c_;
         ^
  2 errors generated.
  </code></pre>
  
  <p>Getting this after I added <code>c_()</code>:</p>
  
  <pre><code>test.cpp:31:22: note: passing argument to parameter 'c' here
  test.cpp:31:36: error: reference to type 'Child' requires an initializer
          Other(Child &amp;c=Child2()) : c_()
  </code></pre>