Question: 1 main.cpp In main.cpp do the following step by step: 1. Globally define integer array a[], and initialize it with numbers 6,10,-4, 11, and -2.

 1 main.cpp In main.cpp do the following step by step: 1.

Globally define integer array a[], and initialize it with numbers 6,10,-4, 11,

1 main.cpp In main.cpp do the following step by step: 1. Globally define integer array a[], and initialize it with numbers 6,10,-4, 11, and -2. 2. Globally define character array str[] of length 7, and initialize it with "Hello.". 3. Globally declare vecl to be a vector of integers, and vec2 to be a vector of characters. 4. Define the following functions. (a) Define function void reverseArray (...) that receives an array of any arbitrary type, along with its size (an integer). It reverses the order of array elements (2 points). (b) Define function void printArray (...) that receives an array of any arbitrary type, along with its size (an integer). It prints out the array elements (2 points). (c) Define function void initVector (...) that receives 1) a vector of any arbitrary type as a reference, 2) an array of the same type as the elements of the input vector, and 3) the size of the array (an integer). It initializes the input vector with the elements existing in the input array (2 points). (d) Define function void replaceLast Three (...) that receives a vector of any arbitrary type as a reference and three items of the same type as the elements of the input vector. It replaces the last three elements of the vector with those three input items in order) (3 points). (e) Define function void print Vector (...) that receives a vector of any arbitrary type and prints out its elements (2 points). (f) Define class Comparable which (i) has two private data components of the same type, named iteml and item2 (2 points). (ii) has public function bool lt () that checks if iteml is less than item2 (2 points). (iii) has public function bool gt() that checks if iteml is greater than item2 (2 points). (iv) has public function bool eq) that checks if iteml is equal to item2 (2 points). (v) has constructor Comparable(...) that receives two inputs of the same type as the private data components and assigns the first input to iteml, and the second input to item2 (2 points). In main() function do the following step by step, using the functions defined above: (1) Call reversing array function from above on a [] and the appropriate size (1 points). (II) Print out the content of a [] using printArray function (1 points). (III) Call the same reversing array function from above on str[] and the appropriate size (1 points). (IV) Print out the content of str[] using the same printArray function (1 points) (V) Initialize veci according to a [] using the initialization function from above (1 points). (VI) Print out the content of vecl using print Vector function (1 points). (VII) Initialize vec2 according to str[] using the same initialization function from above (1 points). (VIII) Print out the content of vec2 using the same print Vector function (1 points). (IX) Replace last three elements of vecl with 9, 0, and 2, using the appropriate function from above (1 points) (X) Print out the content of vecl using print Vector function (1 points). (XI) Replace last three elements of vec2 with 'f', 'y', and 'o', using the same appropriate function from above (1 points). (XII) Print out the content of vecl using the same print Vector function (1 points). (XIII) Declare a Comparable object compl with initial values 3 and 5 for iteml and item2, respec tively (1 points). (XIV) Declare a Comparable object comp2 with initial values 'r' and 'b' for iteml and item2, respectively (1 points). (XV) Run It() for comp1 and print out the result (1 points). (XVI) Run eq() for comp2 and print out the result (1 points) The output of the program may look like the following: Reverse all: -2, 11, -4, 10, 6 Reverse str[]: 1 ., , 1, 1, e, H Initialize vecl according to a[]: -2, 11, -4, 10, 6 Initialize vec2 according to str[]: , ., 0, , , e, H Replace last three elements of vecl with 9, 0, and 2: -2, 11, 9, 0, 2 Replace last three elements of vec2 with 'f', 'y', and 'o': 1 , 0, 1, f, y, o Is 1st component of compl less than 2nd component of it? 1 Is lst component of comp2 equal to 2nd component of it? 0

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!