title: C++ Error getting the derived class to display a variable in a abstract class that has a aggregation relation with the parent of the derived class
body: <p>I'm trying to get my derived class(humanplayer) to make a variable member function of abstract(Vector) equal to "hi" so that I can display that but the compiler acts all weird and says EXC_BAD_ACCESS(code=EXC_I386_GPFLT).</p>
  
  <p>Here is my header file:</p>
  
  <pre><code>#ifndef __testing_more_stuff__vector__
  #define __testing_more_stuff__vector__
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  class Vector{//abstract class
  public:
      void setName(string name_holder);
      virtual void test()=0;
  protected:
      string name;
  
  };
  
  class player{//base class that has an aggregation relationship with vector
  
  protected:
      Vector *molo;
  };
  
  
  class humanplayer:public player//derived class of player
  {
  public:
      void play();
  };
  
  #endif
  </code></pre>
  
  <p>Here is my implementation file:</p>
  
  <pre><code>#include "vector.h"
  
  void Vector::setName(string name_holder)
  {
      name=name_holder;
      cout&lt;&lt;name&lt;&lt;endl;
  }
  
  void humanplayer::play()
  {
      molo-&gt;setName("hi");//since humanplayer inherits from player it should be able to set name to hi and print it out
  }
  </code></pre>
  
  <p>Here is my test/main file:</p>
  
  <pre><code>#include "vector.h"
  
  
  int main()
  {
     humanplayer x;
  
     x.play();
  }
  </code></pre>