Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 2: A Bar Chart Points: 35% Required API Implement class Chart, to represent a Bar Chart. Each Chart has: An array of objects of
Part 2: A Bar Chart Points: 35% Required API Implement class Chart, to represent a Bar Chart. Each Chart has: An array of objects of type Bar. This is provided by the user of the class through the constructor. A title. This is a string that describes the chart. A maximum size. This is a constant positive integer that controls the size of the chart. You must implement the following public functions: // constructor (n is the size of the array). Chart(Bar b[], int n, string title, int MAX_SIZE) // copy constructor Chart(const Chart& other); // destructor -Chart(); // sorts the bars in the chart in "descending" or void sort(); // displays the top m bars in the chart. void show(string caption, int m) const; Constructors and Destructors Use dynamic memory allocation in the constructor to create the array of Bar objects and copy into it the elements of the received array. Each Chart object must store and manage its own array of Bar objects, such that the array is not modifiable through any reference outside the class. Implement the copy constructor also such that the object gets its own independent copy of the array of Bar objects in the other Chart. The destructor must deallocate any dynamically allocated memory. Sorting The function sort() must sort the bars in the chart in decreasing order based on their lengths. Modify the following implementation of Bubble Sort to achieve this: for (int i = 0; i
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