CJCoding With Joseph
15free / daySign inCreate account

TeamSheet Owns a new[] Array of Players

Player is already written in the starter code - leave it as is. Write the class TeamSheet, which owns a heap-allocated array of Player objects (not an array of pointers).

Private members:
- Player* players;
- int count;

Public interface used by the hidden driver:
``
TeamSheet(int n);      // allocate n Player objects with new[]; set every jersey and points to 0
~TeamSheet();          // release the array
void setPlayer(int index, int jersey, int points);
int pointsOf(int index) const;
int topJersey() const; // jersey of the player with the most points; on a tie, the LOWEST index wins
`

The driver reads n, then n lines of jersey points, then prints three lines.

For the input:
`
3
7 10
23 14
9 14
``

the exact output is what is shown in Expected Output.

Free the memory you allocate — this question checks for memory leaks.

Do NOT write a main function.

Expected Output:

players=3
points[1]=14
top=23

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Pointers
📥 Auto-Input:
3\n7 10\n23 14\n9 14\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.