int memory1, memory2, memory3, memory4; PlayerT player1, player2, player3, player4;
int turn{0}; while (gameNotOver) { switch (turn) { case 0: TakeTurn(player1); break; case 1: TakeTurn(player2); break; case 2: TakeTurn(player3); break; case 3: TakeTurn(player4); break; } turn ++ turn = turn % 4; }
PlayerT player[4]; int turn{0}; while (gameNotOver) { TakeTurn(player[turn]); turn ++; turn %= 4; }
type identifier[const integer expression];
const int MAX_PLAYERS{4}; const int MAX_VALUES{15}; ... // this is bad int numbers[10]; // this is better int values[MAX_VALUES]; PlayerT player[MAX_PLAYERS]; // this is not legal int size; cin >> size; char letters[size];
int numbers[MAX_NUMBERS} {1,2,3,4,5};
size_t
array[index]
can be used on the left hand or right hand side of an expression.