1
General / Difference of passing a * parameter and a & parameter
« on: June 10, 2017, 03:27:30 pm »
I was reading a tutorial on the internet about game states and then they showed a class of game state with these functions in it:
My question is, why is the changeState and pushState need a parameter with *? I thought you would use the & symbol if you want to pass the actual object/variables instead of the copy. Is there any difference? Thank you in advance!
Code: [Select]
class CGameEngine
{
public:
//... some functions
void ChangeState(CGameState* state);
void PushState(CGameState* state);
private:
// the stack of states
vector<CGameState*> states;
//... some variables
};
My question is, why is the changeState and pushState need a parameter with *? I thought you would use the & symbol if you want to pass the actual object/variables instead of the copy. Is there any difference? Thank you in advance!