title: c++ template specialization method question
body: <p>I'm new to C++ and I'm trying to use template but I got problems.
  What I'm trying to do is: try to calculate square of a number using template, and the number may be basic data types like int, float, as well as complex numbers. I also implemented a complex class using template, and the codes are as follows:</p>
  
  <pre><code>template &lt;typename T&gt;
  class Complex {
  public:
    T real_;
    T img_;
  
    Complex(T real, T img) : real_(real), img_(img) { } 
  };
  
  template &lt;typename T&gt;
  T square(T num) {
    return num * num;
  }
  
  template &lt;&gt;
  Complex&lt;typename T&gt; square(Complex&lt;typename T&gt; num) {
    T temp_real = num.real_*num.real_ - num.img_*num.img_;
    T temp_img  = 2 * num.img_ * num.real_;
    return Complex(temp_real, temp_img);
  }
  </code></pre>
  
  <p>I tried to use template specialization to deal with the special case, but it gave me error:</p>
  
  <pre><code>using ‘typename’ outside of template
  </code></pre>
  
  <p>and the error happens on the template specialization method. Please point out my mistakes. Thanks.</p>