I have a class like this:
class MyClass
{
public:
MyClass();
~MyClass();
void addPlayer(Player* player);
private:
Player* p_player;
}
The method addPlayer tries to accomplish the following:
p_player = player;
The idea is to store the information about an object of type Player in order to have access to dynamically check its position. This solution, however, results in "Access violation writing location". Using:
Player* _player = player;
In the function will not crash, but this means I'm not storing the pointer in the class itself to use in other functions of that class.
EDIT: The issue is most likely a problem related with somewhere else in the project. I will redo a part of the project from scratch more carefully. Thank you for the answers.