C++ Access violation when passing variable
<p>Heres my problem, if I pass a variable from class A to class B via function, then in class B pass that variable to other functions for testing then it works fine. 
But if I pass the variable from A to B then try assigning it to a variable in class B, it gives the error for no reason</p>

<pre><code>//Globals.h
enum TypeofObject { CIRCLE, SQUARE, RECTANGLE, DIAMOND };

//Object.h
#include "Globals.h"
class Object
{
    void Update();
private:
    TypeofObject currentObject;
    CollisionDetection * gameCollision;
};
//Object.cpp
void Object::Update()
{
    //Do stuff here
    gameCollision -&gt; testCollision(currentObject);
}

//CollisionDetection.h
#include "Globals.h"
class CollisionDetection
{
public:
    void testCollision(TypeofObject currentObject);
private:
    void checkObjects(TypeofObject currentObject);
    TypeofObject currentObject;
}

//CollisionDetection.cpp
void CollisionDetection::testCollision(TypeofObject curObject)
{
    currentObject = curObject; //&lt;- If I have this then it gives access violation error

    checkObjects(curObject); //&lt;- Passing it from one function to the next works 
                             //fine but I want to assign it to currentObject so
                             //it doesnt need to be passed
}
</code></pre>
