error problems

im writing a function that will calculate the length of a players first and last name then swapping them if the length of player1 is greater than player2, but when I try compiling the code I get the error

"no match for 'operator[]' in 'player[playerNumber]'
1
2
3
4
5
6
7
8
9
  void playOrder(Players& player){

    int player1length=player[0].firstName.length()+player[0].lastName.length();
    int player2length=player[1].firstName.length()+player[1].lastName.length();

    if(player1length>player2length){}
        swap(player[0].firstName,&player[1].firstName);
        swap(player[0].lastName,&player[1].lastName);
}
What is the type of player? You do set it on line 1.

Does type Players have operator[] ? Should it have?

Lines 7 and 8: What is this swap that takes a type and an address?
Topic archived. No new replies allowed.