title: C++ Private variable of a class is a pointer. How do i have to write setter ? + enumeration
body: <p>Hi everyboy :) I m pretty new on programming and especially on C++. 
  This is why I am trying to test some beginners functions like getters and setters with private variable which are, in fact, pointers. I m doing this tests for an assignement and i have to use enumeration too.<br>
  I got 0 compilation error but my test program is crashing when i m trying to set my private pointer with an enum type. </p>
  
  <p>Here is my class "Slot": header file : Slot.hpp </p>
  
  <pre><code>#ifndef SLOT_H
  #define SLOT_H
  
  enum Pawn{YELLOW, RED};
  
  class Slot
  {
  public:
      Slot();
      ~Slot();
      Slot(const Slot&amp; slot_to_copy) {color = new Pawn(*(slot_to_copy.color));}
  
      void setColor(Pawn);
      Pawn getColor();
  
  private:
      Pawn *color; 
  };
  
  #endif
  </code></pre>
  
  <p>Here is my source file: Slot.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Slot.hpp"
  
  using namespace std;
  
  Slot::Slot() {color = NULL;}
  
  Slot::~Slot() {}
  
  void Slot::setColor(Pawn col)
  {
      *color = col;
  }
  
  Pawn Slot::getColor()
  {
      return *color;
  }
  </code></pre>
  
  <p>And here is my main where I am testing the getter and the setter:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Slot.hpp"
  
  using namespace std;
  
  int main()
  {
      Slot test;
      test.setColor(YELLOW); // testing the setter
      Pawn coin = test.getColor(); // testing the getter
      if (coin == YELLOW)
          cout &lt;&lt;"SUCCESS"&lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>My problem is located on the setter function ... 
  Thank you in advance for your help, i already took 3 hours by trying to fix my problem and I cannot work on my assignement without this working correctly :/
  Sorry for my approximate English by the way.  </p>
  
  <p>PS: I HAVE TO use pointer for that, because it is asked by my teacher and consist in the difficulty (or at least a part of it) of our programming assignement.</p>