title: How do I declare and initialize a 2d int vector in C++?
body: <p>I'm trying to do something like:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;ctime&gt;
  
  class Clickomania
  {
      public:
          Clickomania();
          std::vector&lt;std::vector&lt;int&gt; &gt; board;
  };
  
  Clickomania::Clickomania()
      : board(12, std::vector&lt;int&gt;(8,0))             &lt;&lt;&lt;&lt;&lt;&lt;&lt;
  {
  
      srand((unsigned)time(0));
  
      for(int i = 0; i &lt; 12; i++)
      {
          for(int j = 0; j &lt; 8; j++)
          {
              int color = (rand() % 6) + 1;
              board[i][j] = color;
          }
      }
  }
  </code></pre>
  
  <p>However, apparently I can't initialize the "board" vector of vectors this way.</p>
  
  <p>How can I create a public member of a 2d vector type and initialize it properly?</p>