title: Access violation reading location 0xFFFFFFFFFFFFFFFF
body: <p>I'm attempting to use OpenGL to demonstrate hierarchical animation. In the early stage I'm trying to give my "bone" object a reference to its parent.</p>
  
  <p>In my bone class, I can add a parent successfully however the issue is when I call <code>hasParent()</code>. It can't read this->parent and crashes with the following exception:</p>
  
  <blockquote>
    <p>Unhandled exception at 0x00007FF6CB723D43 in myprogram.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.**</p>
  </blockquote>
  
  <p>Snippets from my bone class:</p>
  
  <pre><code>void Bone::addParent(Bone *bone)
  {
      this-&gt;parent = bone;
      assert(this-&gt;parent);
  }
  
  bool Bone::hasParent()
  {
      assert(this-&gt;parent); //this line causes the error
      if (this-&gt;parent)
          return true;
      else return false;
  }
  
  glm::mat4 Bone::getBoneModel()
  {
      glm::mat4 parentModel = glm::mat4(1.0);
      if (hasParent())
          parentModel = parent-&gt;getBoneModel();
      //boneModel = parentModel * boneModel;
      return boneModel;
  }
  </code></pre>
  
  <p>Stripped down content of my main:</p>
  
  <pre><code>#define NUMBONES 3
  Bone bone[NUMBONES];
  
  int main( void )
  {
      //------------------ Create Bones --------------------------
      float y = 0.0f;
      for (int i = 0; i &lt; NUMBONES; i++)
      {
          bone[i] = Bone(i, vec3(0, y, -30), vec3(0, 0, 0), vec3(0, 0, 0));
          y += 5.0f;
      }
  
      //----------------- Make relationships ----------------
      bone[0].isRoot = true;
      bone[0].addChild(&amp;bone[1]);
      bone[0].addChild(&amp;bone[2]);
      bone[1].addParent(&amp;bone[0]);
      bone[1].addChild(&amp;bone[2]);
      bone[2].addParent(&amp;bone[1]);
  
      do{
          ModelMatrix = bone[1].getBoneModel();
      }
      return 0;
  }
  </code></pre>
  
  <p>I find references and pointers difficult to get my head around so I'm hoping this is obvious to someone else!</p>
  
  <p>EDIT: </p>
  
  <p>My constructors:</p>
  
  <pre><code>Bone::Bone() {
      parent = NULL;
      child = NULL;
      boneID = 0;
      boneModel = glm::mat4(1.0);
  }
  
  Bone::Bone(int ID, glm::vec3 T, glm::vec3 R, glm::vec3 S)
  {
      boneID = ID;
      isRoot = false;
      pos = T;
  
      //---------- set boneModel ------------------
      glm::mat4 RotationMatrix = glm::mat4(1.0);
      glm::mat4 TranslationMatrix = translate(glm::mat4(), pos);
      glm::mat4 ScalingMatrix = scale(glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f));
      boneModel = TranslationMatrix * RotationMatrix * ScalingMatrix;
  
      std::cout &lt;&lt; "bone[" &lt;&lt; boneID &lt;&lt; "] created.\n";
  
  }
  </code></pre>