title: Can I have specialized template like here?
body: <p>I want to have general class Vector of any dimensions with template type </p>
  
  <pre><code>template &lt;typename T, unsigned D&gt;
  class Vector {
  public:
      // constructors, methods and so on
  
  protected:
      T data[D];
  };
  </code></pre>
  
  <p>and specializations for 2, 3 and 4 dimensions </p>
  
  <pre><code>template &lt;typename T, unsigned D&gt;
  class Vector&lt;T, 3&gt; {
  public:
      T getX() const { return data[0]; }
      // ... 
  };
  </code></pre>
  
  <p>this code, of course, doesn't work. How should I do it? If it is possible. Or, in any cases, I should use inheritance?</p>
  
  <pre><code>template &lt;typename T&gt;
  class Vector3 : public Vector&lt;T, 3&gt; {
  public:
      T getX() const { return data[0]; }
  };
  </code></pre>