Original Post
Hello
I have a three classes called Player, Enemy and Bullet and finally my main function.
now in every class there is a function to get their X and Y position. I call all the classes in the Main function and they work perfectly. Now my problem is if I just want to call the Player.GetXPosition() in Enemy class or Bullet class I get 0. But if I call Player.GetXPosition() in the Main function I get the value.
This problem has been hunting me in all of my projects and its driving me crazy. Now I think i can solve this problem by passing the Memory address of Player.GetXPosition() to Enemy class or Bullet class and I'll get the value, but i don't know how to do this.
please guys help me.
BTW i'm using c++.
I have a three classes called Player, Enemy and Bullet and finally my main function.
now in every class there is a function to get their X and Y position. I call all the classes in the Main function and they work perfectly. Now my problem is if I just want to call the Player.GetXPosition() in Enemy class or Bullet class I get 0. But if I call Player.GetXPosition() in the Main function I get the value.
This problem has been hunting me in all of my projects and its driving me crazy. Now I think i can solve this problem by passing the Memory address of Player.GetXPosition() to Enemy class or Bullet class and I'll get the value, but i don't know how to do this.
please guys help me.
BTW i'm using c++.