Question: use c + + Part - C ) . [ 1 0 % ] Further implement a class MyClassArr as the datatype of variables to
use cPartC Further implement a class MyClassArr as the datatype of variables to store in an MyArrayMyArray
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 mArrayNULL, Len
MyClassArrint arr int l:the parameterized constructor to initialize mArray with the
values of arr, and Lenl
MyClassArrconst 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 a and a as follows:
o Compare arr and arr integer by integer from the beginning of both dynamic arrays ie
apAddress and apAddrerss used to store the integers.
o If the i integers of the two objects are identical, then:
a If ith integer of a is larger than a a is larger than a regardless the remaining part;
b If ith integer of a is smaller than a s is smaller than s regardless the remaining part;
c If ith integer of s is equal to s continue the operation on ith 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 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 ie mArray.mSize
mArray.mCapacity
ExampleInput is underlined:
Input the amount of variables to store in the MyClassArr array:
Input the size of MyArray :
Input array :
Input the size of MyArray :
Input array :
Input the size of MyArray :
Input array :
The max value of the array is:
ExampleInput is underlined:
Input the amount of variables to store in the MyClassArr array:
Input the size of MyArray :
Input array :
Input the size of MyArray :
Input array :
Input the size of MyArray :
Input array :
Input the size of MyArray :
Input array :
Input the size of MyArray :
Input array :
Input the size of MyArray :
Input array :
Inserting new value failed: the array is full.
Input the size of MyArray :
Input array :
Inserting new value failed: the array is full.
The max value of the array is:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
