title: Why does this C++ code cause a runtime error?
body: <p>I get the following error when I try to run this code in Visual Studio 2010:</p>
  
  <blockquote>
    <blockquote>
      <p>Unhandled exception at 0x012c23d3 in matrix.exe: 0xC0000005: Access violation reading location 0xccccccd0.</p>
    </blockquote>
  </blockquote>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;vector&gt;
  
  using namespace std;
  
  class matrix : public vector&lt;vector&lt;char&gt;&gt; {
    public:
      matrix(int x, int y) {
          this-&gt;resize(x);
          for (int i = 0; i &lt; y; ++i) {
              this[i].resize(y);
          }
      }
  };
  
  void main() {
      matrix mat(10, 10);
  }
  </code></pre>
  
  <p>I'm trying to create a <code>matrix</code> class that expands on the <code>vector&lt;vector&lt;char&gt;&gt;</code> type by adding built-in matrix manipulation functions. However, I can't get this constructor to run properly.</p>
  
  <p>Thanks for your help.</p>