title: Exc_bad_access with pointers
body: <p>I have been working in a project using matrices and graphs. The problem is when I compile it, the next line pops up:</p>
  
  <blockquote>
    <p>EXC_BAD_ACCESS (code=2, address=0x7ffff5f3ffff8)</p>
  </blockquote>
  
  <p>It appears in the next method; which is a constructor of my class:</p>
  
  <pre><code>GrafoMatriz::GrafoMatriz(){
      maxVerts = 1;
      GrafoMatriz(maxVerts);
  }
  </code></pre>
  
  
  
  <pre><code>typedef int * pint;
  
  class GrafoMatriz {
      ...
      int maxVerts;
      int numVerts; 
      Vertice * verts; // there's another class Vertice
      int ** matAd; 
  
      GrafoMatriz();
      GrafoMatriz(int mx); 
      ...
  }
  
  GrafoMatriz::GrafoMatriz (int mx){
      maxVerts = mx;
      verts = new Vertice[mx]; 
      matAd = new pint[mx]; 
      numVerts = 0;
      for (int i = 0; i &lt; mx; i++)
          matAd[i] = new int[mx];
  }
  </code></pre>
  
  <p>I have been reading about possible problems and it could be something wrong about pointers:</p>
  
  <blockquote>
    <p>The pointer could have never been initialized.</p>
    
    <p>The pointer could have been accidentally written over because you overstepped the bounds of an array.</p>
    
    <p>The pointer could be part of an object that was casted incorrectly, and then written to.</p>
    
    <p>Any of the above could have corrupted a different pointer that now points at or near this pointer, and using that one corrupts this one (and so on).</p>
  </blockquote>
  
  <p>I guess it's something about my pointer <code>pint</code>, but I am new to C++. So, I haven't been able to fix it. By the way0, I'm using Xcode 6.4 on an Intel Macbook Pro.</p>