Passing a value from a different class into integer

Hi everyone!

I am just beginning my adventure with programming and I am already having some difficulties.

I am trying to make a 2d game with a player and an enemy class. I would like my enemy to run after the player and so I need to pass an integer with its current position.

How can I pass the x position into another integer so then later I could compare the two of them?

class Player{
int x;
public:
void setA(int posX){
this->x=posX;
}
int getA(){
return this->x;
}
};
Topic archived. No new replies allowed.