title: Setting constructor and destructor with *pointer array C++
body: <p>I am using <code>int *studentsAge</code> to store a list of ages,  and <code>double *marks[2]</code> to store a list of 2 marks per student.</p>
  
  <p>Basically, I am not sure how to set my <code>constructor</code> and <code>destructor</code>.</p>
  
  <p>This is my constructor...</p>
  
  <pre><code>Students::Students()
  {
    num = 0;
    studentsAge = NULL;
    marks[2] = NULL;
  }
  </code></pre>
  
  <p>I use both pointer arrays in this function...</p>
  
  <pre><code>void Students::storeValues(int num)
  {
     this-&gt;num = num;
     studentsAge = new int[num];
     for(int i=0; i&lt;num; i++)
     {
       studentsAge[i] = i;
       marks[i] = new double[num]
     }
  }
  </code></pre>
  
  <p>This is my destructor...</p>
  
  <pre><code>Students::Students()
  {
     for(int i=0; i&lt;num; i++)
     {
        delete[] marks[i];
        delete[] studentAge[i];
     }
     delete[] marks;
     delete[] studentAge
  }
  </code></pre>
  
  <p>I am not sure if my <code>constructor</code> and <code>destructor</code> are right and I can suspect a memory leak somewhere. I am not too good with pointers, but I would appreciate it if someone could tell me where I am going wrong</p>