Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Passing Class by Reference  (Read 1027 times)

0 Members and 1 Guest are viewing this topic.

JasonMcG

  • Newbie
  • *
  • Posts: 10
    • View Profile
Passing Class by Reference
« on: September 18, 2017, 08:58:51 pm »
I have a player class which house my player move function.

I have a second class, a rock class. In this rock class, I need to pass the position of the player at its current time. How do I go about doing that? Do I pass the entire class by reference? since I always need the new and current value of player.

Martin Sand

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Passing Class by Reference
« Reply #1 on: September 19, 2017, 10:36:06 pm »
Ok, can you give a bit more context? What to you do in the rock class?

And yes, if you need to have the new and current values and they are either held by the player class or are based on values in the player class, you probably need to pass it by reference.

 

anything