title: Getting error C2512 in constructor call
body: <p>I am getting error C2512 when I am calling the constructor of a class from another class's constructor. I am using template instances at the bottom of the file, so that I wouldn't have to implement the member functions in the header. Normally, this is caused by not having a default constructor, but I do.</p>
  <h3>vec.h</h3>
  <pre><code>template &lt;class TYPE&gt; class vec {
      struct vecimp;
      vecimp *imp;
  public:
      vec() { }
      vec(const TYPE *, size_t);
      ~vec();
  };
  </code></pre>
  <h3>vec.cpp</h3>
  <pre><code>#include &quot;vec.h&quot;
  template &lt;class TYPE&gt; struct vec&lt;TYPE&gt;::vecimp {
      TYPE *arr;
      size_t n;
      vecimp(const TYPE *arr, size_t n)
      {
          this-&gt;arr = (TYPE *) malloc(n * sizeof(TYPE));
          this-&gt;n = n;
      }
      ~vecimp()
      {
          free(this-&gt;arr);
          this-&gt;arr = NULL;
      }
  };
  
  template &lt;class TYPE&gt; vec&lt;TYPE&gt;::vec(const TYPE *arr, size_t n)
  {
      this-&gt;imp = 
          new vecimp
          &lt;TYPE&gt;             // C2512 occurs here
          (arr, n);
  }
  
  // member function implementations, dtor, etc
  
  template class vec&lt;int&gt;;
  </code></pre>
  <p>Here is the error message text</p>
  <blockquote>
  <p>'vec::vecimp': no appropriate default constructor available</p>
  </blockquote>
  <p>So I tried to add a default constructor to my <code>vecimp</code> class, but then it gave me the compiler error C2275, at the same place as now.</p>