Question: use c + + Part - C ) . [ 1 0 % ] Further implement a class MyClassArr as the datatype of variables to

use c++Part-C).[10%] Further implement a class MyClassArr as the datatype of variables to store in an MyArrayMyArray*mSize==MyCl>>i-1a2,s1s2
object. The class MyClassArr stores integers through MyArray. It contains two private values:
MyArray* mArray: a pointer of MyArray. It points to the object of MyArray that
stores the integers.
MyClassArr further contains the following public member functions:
MyClassArr():the default constructor to initialize mArray=NULL, Len=0.
MyClassArr(int arr[], int l):the parameterized constructor to initialize mArray with the
values of arr, and Len=l.
MyClassArr(const MyClassArr& a):the copy constructor that uses another object a to
initialize the current object. Because mArray contains dynamic array (defined in class MyArray), use
deep copy by creating a new object of MyArray and calling pushBack() function.
~MyClassArr():the destructor to release the memory occupied by mArray.
operator=: overload the operator= that copies the value of another object to the current object.
Use deep copy with the same principle as the copy constructor.
operator: overload the operator to print the integers stored in mArray. There is a space
between the adjacent integers as shown in the example. The overloaded operator should
support chain function calls.
operator>: overload the operator> to compare two objects through the value of their member
variables mArray. Return true if the current object is larger; otherwise return false.
We define the rule to compare two MyArray objects a1 and a2 as follows:
o Compare arr1 and arr2 integer by integer from the beginning of both dynamic arrays (i.e.,
a1.pAddress and a2.pAddrerss) used to store the integers.
o If the i-1 integers of the two objects are identical, then:
a. If ith integer of a1 is larger than a2, a1 is larger than a2 regardless the remaining part;
b. If ith integer of a1 is smaller than a2, s1 is smaller than s2 regardless the remaining part;
c. If ith integer of s1 is equal to s2, continue the operation on i+1th bit until the dynamic
array pAddress of one object ends;
o When the dynamic array of one object ends, and there is still no result for the comparison, the
object with longer length (mSize) is larger. If the lengths of the two objects are identical, the
two object are equal.
Create an object of MyArray by assigning the template T as MyClassArr with capacity of 5. We will first provide
the amount of MyClassArr objects in the input. Then the size and the content of int arrays to store in each
MyClassArr object will be provided. After reading the inputs properly, print the max variables storing in the
object as shown in the examples.
Note: You need to overload the operators of MyClassArr correctly in order to call the function getMax()
defined in MyArray.
Len: stores the length of mArray.
For MyClassArr, we assume that its member mArray is fully occupied (i.e., mArray.mSize ==
mArray.mCapacity).
Example-1(Input is underlined):
Input the amount of variables to store in the MyClassArr array:
3
Input the size of MyArray 1:
3
Input array 1:
323
Input the size of MyArray 2:
2
Input array 2:
110
Input the size of MyArray 3:
2
Input array 3:
32
The max value of the array is: 323
Example-2(Input is underlined):
Input the amount of variables to store in the MyClassArr array:
7
Input the size of MyArray 1:
6
Input array 1:
345123
Input the size of MyArray 2:
3
Input array 2:
346
Input the size of MyArray 3:
1
Input array 3:
2
Input the size of MyArray 4:
4
Input array 4:
1342
Input the size of MyArray 5:
2
Input array 5:
34
Input the size of MyArray 6:
6
Input array 6:
355123
Inserting new value failed: the array is full.
Input the size of MyArray 7:
3
Input array 7:
331
Inserting new value failed: the array is full.
The max value of the array is: 346
use c + + Part - C ) . [ 1 0 % ] Further

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 Programming Questions!