SFML community forums

Help => General => Topic started by: JasonMcG on September 18, 2017, 08:58:51 pm

Title: Passing Class by Reference
Post by: JasonMcG 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.
Title: Re: Passing Class by Reference
Post by: Martin Sand 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.