title: C++: Default initialize an integral type in a template function
body: <p>For educational purposes I am wrting my own C++ numerical vector template class. I want to be able to write (v, w) for the dot product of two vectors and consequently overload <code>operator,()</code> as follows:</p>
  
  <pre><code>template&lt;class T&gt;
  const T Vector&lt;T&gt;::operator,(const Vector&lt;T&gt;&amp; v) const
  {
      assertEqualSize(v);
  
      T t;
      for(size_t i=0; i&lt;numElements; i++) {
          t += elements[i] * v[i];
      }
      return t;
  }
  </code></pre>
  
  <p>My question now is: how do I properly initialize <code>t</code> with a sensible value (e.g. <code>0.0</code> for <code>Vector&lt;double&gt;</code>)? I tried <code>T t();</code> but then g++ tells me, e.g., that "double(*)()" cannot be converted to "const double" at the return statement and that <code>operator+=()</code> would not be defined for "(double(), double)".</p>
  
  <p>Thank you very much!</p>