How to overload a constructor outside of the class definition in c++
<p>Okay, so I have been working on a homework project and found a way that will let me finish the homework and get it turned in, but it is still bothering me. </p>

<p>I have a base class that is dynamically allocating some other classes, and a Derived class.</p>

<pre><code>
//header
class Base 
{
Private:
   Type *type_ptr;
Public:
   Base();
   Base(Type &new_type);
   //getters and setters
}

class Derived : public Base
{
Private:
  Type2 *type2_ptr;
Public:
 Derived();
 Derived(Type, Type2) : Base(Type);

}
 </code></pre>

<p>What I want to figure out is what this should look like in my .cpp file, instead of doing it in-line like so,</p>

<pre><code>Derived(Type new_type, Type2 new_type2): Base(new_type){
  type2_ptr = new Type2(new_type2);
};
</code></pre>

<p>edit: if I try something like the above in my .cpp that I get errors like this, always two of them too...</p>

<pre><code>undefined reference to `vtable for Derived'
undefined reference to `vtable for Derived'
</code></pre>
