********C++ ********HELP**********************************cw Define a dynamic ar
ID: 3757093 • Letter: #
Question
********C++ ********HELP**********************************cw
Define a dynamic array class whose data members are private.
class dynamicArray
{
public:
void show();
dynamicArray(int new_size = 8);
dynamicArray(const dynamicArray& new_array);
const dynamicArray& operator=(const dynamicArray& source);
private
int *elts;
int size;
}
Define the default constructor, copy constructor, assignment function, and show method
The elements of the array are the digits from 0 to 9.
Define a function that multiplies the elements of two arrays. The function returns the product of the array elements. If the product of two array elements is too big to fit in an array position then some of the product carries to the next higher position in the array. The function's prototype is
dynamicArray multiply(const dynamicArray& da1, const dynamicArray da2);
Explanation / Answer
#include using namespace std; class dynamicArray { public: void show(); dynamicArray(int new_size = 8); dynamicArray(const dynamicArray& new_array); const dynamicArray& operator=(const dynamicArray& source); dynamicArray multiply(const dynamicArray& da1, const dynamicArray da2); private: int *elts; int size; }; dynamicArray::dynamicArray(int new_size) { elts = new int[new_size]; size = new_size; } dynamicArray::dynamicArray(const dynamicArray &new_array) { size = new_array.size; elts = new int[size]; for(int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.