Write a class that tracks the five highest scores for a game. The scores should be stored in a file and include the player’s name as a string and the player’s score as an integer. The list of top scores should initially consist of the name Anonymous and scores of 0. The class should support the following functions: ■ A way to output to the screen the name and score of the top five players. The scores should be listed in order, with the highest score first and the lowest score last.
■ A function that takes a new name and score. If the score is higher than any of the top five scores then it should be added to the file and the lowest score discarded. Otherwise, the top list should remain unchanged.
Include an appropriate constructor or destructor if necessary, along with any helper functions. Write a main function that tests your class by simulating several score entries and outputting the high score list.
Sorry the answer is not available at the moment…
If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.
Spread the 'tradition of sharing'.