title: How to print out a 2D vector of objects in C++?
body: <p>I'm writing a program which includes a 2D vector of objects:</p>
  
  <pre><code>class Obj{
  public:
      int x;
      string y;
  };
  
  vector&lt;Obj&gt; a(100);
  
  vector&lt; vector&lt;Obj&gt; &gt; b(10);
  </code></pre>
  
  <p>I've stored some values of vector a in vector b.</p>
  
  <p>I get an error when I try to print it out like this:</p>
  
  <pre><code>for(int i=0; i&lt;b.size(); i++){
      for(int j=0; j&lt;b[i].size(); j++)
        cout &lt;&lt; b[i][j];
      cout &lt;&lt; endl;
  }
  </code></pre>
  
  <p>error info:</p>
  
  <blockquote>
    <p>D:\main.cpp:91: error: no match for 'operator&lt;&lt;' (operand types are 'std::ostream {aka std::basic_ostream}' and '__gnu_cxx::__alloc_traits >::value_type {aka Obj}')
           cout &lt;&lt; b[i][j];
                ^</p>
  </blockquote>