title: How to define a 2D array in C++ and STL without memory manipulation?
body: <p>There are several ways to define a 2D array in C++ and STL without memory manipulation, and the following codes illustrate two different methods:</p>
  
  <pre><code>int main () 
  {
      /**************
          1   2   3
          4   5   6
      ***************/
      // Method 1
      const int ROW = 2;
      const int COL = 3;
      int array1[ROW][COL];
      for(int i=0; i&lt;ROW; i++)
          for(int j=0; j&lt;COL; j++)
              array1[i][j] = i*COL+j+1;
  
      // Method 2
      typedef vector&lt;vector&lt;int&gt; &gt; ARRAY; 
      ARRAY array2;
      vector&lt;int&gt; rowvector;
      for(int i=0; i&lt;ROW; i++)
      {
          rowvector.clear();
          for(int j=0; j&lt;COL; j++)
              rowvector.push_back(i*COL+j+1);
          array2.push_back(rowvector);
      }
      return 0;
  }
  </code></pre>
  
  <p>My question is: are there other ways to define the 2D array? Which one is the most efficient one? Thanks!</p>