title: How do I clear 2D Vector in C++
body: <p>Can any one please suggest me, How do I clear 2D vector in C++. 
  I have to write program where I need to read in Matrix , Process and Clear Matrix and get ready for next read operation. I have created 2D array with vector> I am filling  but failing to reset. Below is the code for reference.  </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;algorithm&gt;
  
  
  using namespace std;
  
  
  #define MAX 501
  typedef std::vector&lt;std::vector&lt;int&gt;&gt; vec2d;
  vec2d matrix(MAX , std::vector&lt;int&gt;(MAX, 0));
  
  void main()
  {
      int tc; 
      int N;
  
      for(tc =0 ; tc &lt; 20;tc++)
      {
          int temp;
          scanf("%d",&amp;N); 
  
          int result =0;
  
          for(int i = 0; i &lt; N;i++)
          {
              for(int j=0; j&lt;N;j++)
              {               
                  scanf("%d",&amp;temp);
                  matrix[i][j]=temp;
              }
          }
          // Do Some processing with 2D vectory Array 
  
          matrix.clear(); // Now I want to clear 2D vector but only vector contents, and get ready for new input reading  
                      // How do I do it with 2d Vector ? 
          cout &lt;&lt; result &lt;&lt; endl;
      }
  }
  </code></pre>