Question: Q2. Write a class my Arrays which provides some functions that perform common tasks on arrays/dynamic arrays such as searching, sorting etc. The functions for

 Q2. Write a class my Arrays which provides some functions that

Q2. Write a class my Arrays which provides some functions that perform common tasks on arrays/dynamic arrays such as searching, sorting etc. The functions for this class belong to the class and you do not have to create an object of this class to invoke those member functions (carefully write the function definition). Your class does not have any data members. It has the following functions: A function called fill(which takes as parameters a dynamic array of int followed by three values of type int, and returns nothing. The first parameter of type int represents an arbitrary value, the second int parameter represents a starting position, and third int parameter represents an end position. The function assigns the value in the first parameter of type int to each element of the dynamic array whose position is between the starting position (inclusive) and the end position (exclusive). Sample function call and function output are given below: int x[] = { 5,10,15,7,1,13,21,19); int* xx = x; myArrays::fill(xx, 8, 2, 5); After the execution of the function, your array x should have the following elements: {5,10,0,0,0,13,21,19) A function called copyOft) which takes as parameters a dynamic array of int followed by two values of type int, and returns a dynamic array. The first parameter of type int represents a starting position, and the second parameter of type int represents an end position. This function creates a new array, and copies all elements of the parameter array whose positions are between the starting index (inclusive) and the end index (inclusive) so that the order in which the values appear in the new array is the same as the order in which they appear in the parameter array. Sample function call and function output are given below: int x[] = { 5,10,15,7,1,13,21,19}; int* xx = x; int #newx = myArrays::copyOf(xx, 2, 6); After the execution of the function, your array x should have the following elements: (15,7,1,13,21) Please provide a display function as well which takes a dynamic array as parameter and displays its elements. Demonstrate your class by calling these functions in the main function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!