Question: C++ please. Very confused :( cout //*********** Method with invalid input is Tested *********** DynamicArray Darr3(3); Darr3.addElement(20); Darr3.addElement(22); Darr3.setArraySize(1); if(Darr3.getArraySize() == 3){ cout //*********** Print

C++ please. Very confused :( C++ please. Very confused :( cout //*********** Method with invalid inputis Tested *********** DynamicArray Darr3(3); Darr3.addElement(20); Darr3.addElement(22); Darr3.setArraySize(1); if(Darr3.getArraySize() == 3){ cout//*********** Print Function is Tested *********** DynamicArray Darr4(1); Darr4.addElement(1); Darr4.addElement(2); Darr4.addElement(3); strings = Darr4.print(); string str1 = "1,2,3"; if(s == str1 ){ cout

cout

//*********** Method with invalid input is Tested *********** DynamicArray Darr3(3); Darr3.addElement(20); Darr3.addElement(22); Darr3.setArraySize(1); if(Darr3.getArraySize() == 3){ cout

//*********** Print Function is Tested *********** DynamicArray Darr4(1); Darr4.addElement(1); Darr4.addElement(2); Darr4.addElement(3); string s = Darr4.print(); string str1 = "1,2,3";

if(s == str1 ){ cout

}

//*********** Copy Constructor is Tested *********** DynamicArray Darr5(1); Darr5.addElement(10); DynamicArray Darr6 = Darr5; Darr6.addElement(100); Darr6.addElement(1000); string s1 = Darr5.print(); string output1 = "10"; string s2 = Darr6.print(); string output2 = "10,100,1000"; //if(Darr.getnumOfElements() == 3 && Darr.getarraySize() == 4) if (s1==output1 && s2==output2){ cout

}

return 0;

} Sample output

Correct Result array Size after expansion is : 8

Correct Result array Size after given wrong value (less than one) : 1

Correct Result array Size is after given a wrong value (less than actual numOfElements) : 3

Correct Result Elements of array :1,2,3

Correct Result First array has 10 Copied array after modification has 10,100,1000

2- Problem You have to write a class "DynamicArray" to store an dynamic array of integers and allow manipulations on that array. It would have following private attributes: int *arr:A pointer that points to the array. int arraySize: An integer that stores the size of the array. It should be at least size one int numOfElements: An integer that tracks how many elements are in the array. The constructor and copy constrcutor will be defined as follows: Constructor: In constructor a valid arraySize (at least 1) should be passed. If any number less than 1 is passed to the constructor or copy constructor, then you should set arraySize to 1 by default. DynamicArray (int arraySize) Copy Constructor In copy Conctructor, you need to implement Deep Copy, in a way that all elements of one DynamicArray object is copied to the second object. DynamicArray const DynamicArray &a) The class would also include following public accessor functions and methods: Accessors

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!