title: initialize array in constructor
body: <p>I want to have a class which has a member array. The size of the array should be given when I initialize the object. I just found a way with pointers to do this. I think it is working correctly, but can you maybe tell me if this is the best way to do it or if there are any things which do not work which I haven't recognized yet?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Surface {
    private:
      float dx;
      int N;
      float* mesh_points;
  
    public:
      Surface(float, int);
      ~Surface();
      void set_dx (float);
      float get_dx();
  };
  
  Surface::Surface(float dx,int N){
    this-&gt;dx = dx;
    this -&gt;N = N;
    mesh_points = new float[N];
  }
  
  
  void Surface::set_dx (float dx) {
    this-&gt;dx = dx;
  }
  
  
  float Surface::get_dx (void) {
    return dx;
  }
  
  Surface::~Surface(){
    delete[] mesh_points;
  }
  
  int main () {
    Surface s(1.2,10);
    s.set_dx (3.3);
    cout &lt;&lt; "dx: "&lt;&lt; s.get_dx() &lt;&lt;endl;
  
    float mesh_points[3];
    return 0;
  }
  </code></pre>