← Back to Pointers
Question 696
TeamSheet Owns a new[] Array of Players
TeamSheet Owns a new[] Array of Players
Playeris already written in the starter code - leave it as is. Write the classTeamSheet, which owns a heap-allocated array ofPlayerobjects (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 readsn, thennlines ofjersey 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
Sign in to use hintsTopics:
Pointers
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.