Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 3 (25 marks) Implement a C program that helps to explain the syntax and the use of data structures such as arrays and pointers.
Question 3 (25 marks) Implement a C program that helps to explain the syntax and the use of data structures such as arrays and pointers. These data structures form part of the data members and constructors in a C++ class. (a) Declare the data members of Competition class as follows: (i) (ii) (iii) Astring representing the title of the competition. An integer representing the number of players in the competition. A dynamic location large enough to store the names of the players in the competition. The location is reference by a pointer string* players (iv) A dynamic location large enough to store the scores of the players in the competition. The location is reference by a pointer string scores (4 marks) (b) Implement an application using the C language in an object-oriented style Constructors and destructor are used to initialise and remove objects in an object oriented manner. You are asked to write the following constructors to initialise a Competition object and a destructor to remove it from memory (5 marks) (ii) A default constructor (4 marks) (Assuming the competition has at least three players, you may use any valid default values for the title, players and scores) (iii) A copy constructor (6 marks) (iv) A destructor (2 marks) Write a main() function to demonstrate how the constructors in part (b) are being (4 marks) (c) used
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started