I'm working on a program for class, and I almost have it. I just have one more error that I haven't been able to fix. I'm getting the above error in line 42, and I understand what it means, but I don't know how to fix it. The instructions for the assignment said to use reference variables, and taking away the & just gives me a different error anyway. What else could I do to fix this problem? Thanks! Here's my code:
This isn't legal. To understand why, understand that a reference must be initialised when it's declared. Since there's no guarantee that an array will be initialised, there's no guarantee that all references in the array will be initialised. Furthermore, a reference isn't an object, and an array of non-existent objects doesn't make sense.
Initially, I assumed you wanted to reference an array. If I was right, then you want this:
void displayPlayer(Player(&team)[5]);
Here, team is a reference to an array of 5 Player objects. The use of parentheses here tells the compiler that team is a reference.