title: template; Point<2, double>; Point<3, double>
body: <p>I want to create my own Point struct it is only for purposes of learning C++.<br>
  I have the following code:  </p>
  
  <pre><code>template &lt;int dims, typename T&gt;
  struct Point {
      T X[dims];
      Point(){}
      Point( T X0, T X1 ) {
          X[0] = X0;
          X[1] = X1;
      }
      Point( T X0, T X1, T X2 ) {
          X[0] = X0;
          X[1] = X1;
          X[2] = X2;
      }
      Point&lt;dims, int&gt; toint() {
          //how to distinguish between 2D and 3D ???
          Point&lt;dims, int&gt; ret = Point&lt;dims, int&gt;( (int)X[0], (int)X[1]);
          return ret;
      }
      std::string str(){
          //how to distinguish between 2D and 3D ???
          std::stringstream s;
          s &lt;&lt; "{ X0: " &lt;&lt; X[0] &lt;&lt; " | X1: " &lt;&lt;  X[1] &lt;&lt; " }";
          return s.str();
      }
  };
  int main(void) {
  
      Point&lt;2, double&gt; p2d = Point&lt;2, double&gt;( 12.3, 45.6 );
      Point&lt;3, double&gt; p3d = Point&lt;3, double&gt;( 12.3, 45.6, 78.9 );
  
      Point&lt;2, int&gt; p2i = p2d.toint(); //OK
      Point&lt;3, int&gt; p3i = p3d.toint(); //m???
  
      std::cout &lt;&lt; p2d.str() &lt;&lt; std::endl; //OK
      std::cout &lt;&lt; p3d.str() &lt;&lt; std::endl; //m???
      std::cout &lt;&lt; p2i.str() &lt;&lt; std::endl; //m???
      std::cout &lt;&lt; p3i.str() &lt;&lt; std::endl; //m???
  
      char c; std::cin &gt;&gt; c;
      return 0;
  }
  </code></pre>
  
  <p>of couse until now the output is not what I want.
  my questions is:
  how to take care of the dimensions of the Point (2D or 3D) in member functions of the Point?</p>
  
  <p>many thanks in advance<br>
  Oops</p>