title: Declaring a dynamic array without size in header, defining in .cpp
body: <p>I'm writing a class which has dynamic two-dimensional array of integers as a field - most imporant part of it, short access time is preferable. I want to declare it in header file,</p>
  
  <pre><code>//Grid.h
  class Grid{
    int ** array;
  }
  </code></pre>
  
  <p>however the size and contents of it are yet to be defined in constructor implemented in cpp file (propably a read from ini file). </p>
  
  <p>I'm not sure if declaring a <code>int **array</code> pointer in header and assigning later dynamically array to it with use of  </p>
  
  <pre><code>array = new int*[x];  
   for(i=0;i&lt;x;i++){    
  array[i] = new int [y];    
  }
  </code></pre>
  
  <p>will result in creating an array that will be accessible and cause no trouble in other functions calling directly to field of <code>array[i][j]</code> in their definitions (or other less obvious errors), however it's granted that before mentioned functions start calling in, it will and has to be defined already.</p>
  
  <p>My question - it this the valid and efficient way to do it? I'll accept any other ideas.<br>
  Yes, I've heard of "vector" class but I'm not sure about it's efficiency or read-and-write vs integer array performance. Vectors are flexible in size, but I don't need it - my array once set, will have fixed size.</p>
  
  <p>Propably I'm just too used to Java-style <code>int[][] array</code> code.</p>