title: c++ "no appropriate default constructor available" error using template class data member
body: <p>I made a template class Grid(where i said in the header file that the default for T is float), i quoted a part of the source file:</p>
  
  <pre><code>#include"Grid.h"
  
  template &lt;class T&gt;
  Grid&lt;T&gt;::Grid(unsigned int rows=1, unsigned int columns=1)
  :Rows(rows),Columns(columns)
  {
  reset();
  }
  
  template&lt;class T&gt;
  Grid&lt;T&gt;::~Grid(){}
  
  template &lt;class T&gt;
  void Grid&lt;T&gt;::reset()
  {
  vector&lt;T&gt; vec(Rows * Columns,T());
  matrix = vec;
  }
  </code></pre>
  
  <p>And the other member functions can read/change a value of matrix or cout it.</p>
  
  <p>Grid.h:</p>
  
  <pre><code>template&lt;typename T=float&gt; class Grid{
  
  public:
          Grid(unsigned int, unsigned int);
          ~Grid();
          T getValue(unsigned int, unsigned int);
          void setValue(unsigned int, unsigned int, T);
          void reset();
          void write();
  
  private:
          unsigned int Rows;
          unsigned int Columns;
          vector&lt;T&gt; matrix;
  };
  </code></pre>
  
  <p>I found on the internet that in order to use a template class I needed to #include Grid.cpp as well as Grid.h, and doing this I can use the clas Grid and its member functions in my main(). I also put a preprocessor wrapper arround Grid.cpp.</p>
  
  <p>Now, when I try to build a new class PDEProblem, without inheritance but using members from type Grid I get errors:</p>
  
  <pre><code>    Error   2   error C2512: 'Grid&lt;&gt;' : no appropriate default constructor available      c:\users\...  15  
  
      Error   3   error C2512: 'Grid&lt;T&gt;' : no appropriate default constructor available   c:\users\...    15  
  4   IntelliSense: no default constructor exists for class "Grid&lt;float&gt;" c:\Users\...    15
  </code></pre>
  
  <p>PDEProblem.h:</p>
  
  <pre><code>#include"grid.h"
  #include"grid.cpp"
  
  class PDEProblem: Grid&lt;&gt;
  {
  public:
  PDEProblem(unsigned int,unsigned int);
  ~PDEProblem();
  //some more other data members
  
  private:
  Grid&lt;char&gt; gridFlags;
  Grid&lt;&gt; grid;
  unsigned int Rows;
  unsigned int Columns;
  void conPot(unsigned int, unsigned int);
  void conFlag(unsigned int, unsigned int);
  };
  </code></pre>
  
  <p>PDEProblem.cpp:</p>
  
  <pre><code>#include"grid.h"
  #include"grid.cpp"
  #include "PDEProblem.h"
  
  PDEProblem::PDEProblem(unsigned int rows=1,unsigned int columns=1)
      :Rows(rows), Columns(columns)
  {
      conPot(rows, columns);
      conFlag(rows,columns);
  }
  
  PDEProblem::~PDEProblem(){}
  
  void PDEProblem::conPot(unsigned int rows, unsigned int columns)
  {
      grid=Grid&lt;&gt;(rows,columns);
  }
  
  void PDEProblem::conFlag(unsigned int rows, unsigned int columns)
   {gridFlags=Grid&lt;char&gt;(rows,columns);
      // some stuff with a few if and for loops which sets some elements of gridFlags to 1 and the others to 0
  }
  </code></pre>
  
  <p>How can I fix this? It seems to me that I have defaults for everything relevant? 
  Thank you</p>