Question
I am having issues resolving these issues: ElasticArray.cpp:186:24: error: no viable overloaded '=' concatArray[i] = rhs._array[i]; // Copy elements from the left-hand array ~~~~~~~~~~~^ ~~~~~~~~~~~~~
I am having issues resolving these issues:
ElasticArray.cpp:186:24: error: no viable overloaded '=' concatArray[i] = rhs._array[i]; // Copy elements from the left-hand array ~~~~~~~~~~~^ ~~~~~~~~~~~~~ ElasticArray.cpp:99:35: note: candidate function not viable: 'this' argument has type 'const ElasticArray', but method is not marked const const ElasticArray& ElasticArray::operator= (const ElasticArray& array) { ^ ElasticArray.cpp:189:38: error: no viable overloaded '=' concatArray[this->_size + i] = rhs._array[i]; // Copy elements from the right-hand array ~~~~~~~~~~~~~~~~~~~~~^ ~~~~~~~~~~~~~ ElasticArray.cpp:99:35: note: candidate function not viable: 'this' argument has type 'const ElasticArray', but method is not marked const const ElasticArray& ElasticArray::operator= (const ElasticArray& array) {
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here are the instructions:
Create your prototype for the assignment operator now. It is named operator=, it takes a single parameter which should be a constant reference to an ElasticArray, and it returns an ElasticArray by constant reference.
Add an implementation for the assignment operator to your implementation file. Dont forget scope resolution! The implementation should follow the sequence of steps shown in the second figure above, and detailed in the algorithm below.
To assign an ElasticArray source to an ElasticArray destination: 1. de-allocate the array memory owned by the destination object 2. allocate a new array in the destination object that is the same size as the physical size of the source object's array. 3. set the physical and logical size attributes of the destination object to match the source object. 4. copy all values from the source object's logical array into the destination object's logical array. (No need to copy beyond the end of the logical arrays.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started