title: C++ Two Dimensional std::vector best practices
body: <p>I am building an app that needs to have support for two dimensional arrays to hold a grid of data. I have a class <code>Map</code> that contains a 2d grid of data. I want to use vectors rather than arrays, and I was wondering what the best practices were for using 2d vectors. Should I have a vector of vectors of MapCells? or should it be a vector of vectors of pointers to MapCells? or references to MapCells?</p>
  
  <pre><code>class Map {
  private:
      vector&lt;vector&lt;MapCell&gt;&gt; cells;
  
  public:
      void loadMap() {
          cells.clear();
          for (int i = 0; i &lt; WIDTH; i++) {
              //How should I be allocating these?
              vector&lt;MapCell&gt; row(HEIGHT);
              for (int j = 0; j &lt; HEIGHT; j++) {
                  //Should I be dynamically allocating these?
                  MapCell cell;
                  row.push_back(cell);
              }
              cells.push_back(row);
          }
      }
  }
  </code></pre>
  
  <p>Basically what way of doing this is going to get me in the least amount of trouble (with respect to memory management or anything else)?</p>