title: Partial specialization of member variable and method
body: <p>I'm programming a simulation which should both work for 2D and 3D. Now I got objects which surface should be modified. At 3D the surface is a two-dimensional array while with 2D its one-dimensional. I use a template parameter to indicate which dimensional space I use. But when I'm specializing the type of my array I can't specialize the modifying function since it is expected in the specified class. And then I would have to copy all members into the specialized class.</p>
  
  <pre><code>template &lt;class VectorType&gt; class SimulationObject {
      void operateOnSurface();
  };
  
  template&lt;&gt; class SimulationObject&lt;Vector2D&gt; {
      char* surface;
   // Declaration of operateOnSurface expected here
  };
  
  template&lt;&gt; class SimulationObject&lt;Vector3D&gt; {
      char** surface;
  // Declaration of operateOnSurface expected here
  };
  
  template&lt;&gt; void A&lt;Vector2D&gt;::operateOnSurface() {
  }
  
  template&lt;&gt; void A&lt;Vector3D&gt;::operateOnSurface() {
  }
  </code></pre>
  
  <p>But I still want to avoid to copy the code for 2d and 3d since my surface-array and the modifying function are the only members that specify it. So is there another way?</p>