title: Passing a pointer to enum to a function
body: <p>I'm trying to pass an enum declared outside of a function's scope, to a function, so that changing the value of the enum within the function changes the value of the enum pointed to. Using the enum itself just in the scope of the object is not an option as I wish to use this function with multiple different instances of this enum.</p>
  
  <p>I have an enum 'ColourState'. Declared like so. and a pointer to a ColourState.</p>
  
  <pre><code>enum ColourState {COLOUR1, COLOUR2};
  ColourState* CS_GO_score;
  </code></pre>
  
  <p>The pointer was initialised like so.</p>
  
  <pre><code>CS_GO_score = new ColourState;
  *CS_GO_score = ColourState::COLOUR2;
  </code></pre>
  
  <p>I'm now trying to pass the ColourState pointed to by CSS_GO_score to the function 'pulsateColour'</p>
  
  <p>Like so.</p>
  
  <pre><code>void HUD::pulsateColour(GLfloat *colour1, GLfloat *colour2, GLfloat *objectCol, ColourState goingTo, int timeInFrames)
  {
      GLfloat difference[4];
      //give us an array of values to change the array by in the alloted time
      difference[0] = (colour1[0]-colour2[0])/timeInFrames;
      difference[1] = (colour1[1]-colour2[1])/timeInFrames;
      difference[2] = (colour1[2]-colour2[2])/timeInFrames;
      difference[3] = (colour1[3]-colour2[3])/timeInFrames;
  
      //depending on the state, transform the array in one direction or another
  
      if(goingTo == ColourState::COLOUR2)//if we're moving toward colour 2
      {
          for(int i = 0; i&lt;4; i++)
          {
          objectCol[i] -= difference[i];//subract the difference till we get there
          //we need to SNAP to the colour as we will not hit it every time using floats
              if( (objectCol[i]&gt;(colour2[i]-(difference[i]*2))) &amp;&amp; (objectCol[i]&lt;(colour2[i]+(difference[i]*2)))  )
              {//if we hit this tiny but huuuge target
                  objectCol[i] = colour2[i];//SNAP
              }
  
          }
      }else{
          if(goingTo == ColourState::COLOUR1)
          {
              for(int i = 0; i&lt;4; i++)
              {
                  objectCol[i] += difference[i];//add the difference till we get there
                  //we need to SNAP to the colour as we will not hit it every time using floats
              if( (objectCol[i]&gt;(colour1[i]-(difference[i]*2))) || (objectCol[i]&lt;(colour1[i]+(difference[i]*2)))  )
              {//if we hit this tiny but huuuge target
                  objectCol[i] = colour1[i];//SNAP
              }
  
              }
          }
      }
  
      if((objectCol[0] == colour1[0])&amp;&amp;(objectCol[1] == colour1[1])&amp;&amp;(objectCol[2] == colour1[2])&amp;&amp;(objectCol[3] == colour1[3]))
      {//if the objcolour == colour 1
          goingTo = ColourState::COLOUR2;//it's now time to move towards colour 2
      }else{
          if((objectCol[0] == colour2[0])&amp;&amp;(objectCol[1] == colour2[1])&amp;&amp;(objectCol[2] == colour2[2])&amp;&amp;(objectCol[3] == colour2[3]))
          {//if the objcolour == colour 2
              goingTo = ColourState::COLOUR1;//it's now time to move towards colour1  
          }
  
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This function is called like so.</p>
  
  <pre><code>pulsateColour(white,blue, GO_scoreColour, *CS_GO_score, 10);
  </code></pre>
  
  <p>However, when the value pointer to by 'goingTo' and 'CS_GO_score' (they should be the same address therefore technically the same object right?), watching the values monitor in VS i see that only the value pointed to by 'goingTo' (as it is local to the function) is changed? What am I doing wrong?</p>