Question: SET-252 C Programming #2 Homework: 8 Deep copy and more Continued with your code from homework 7. I recommend you make a copy of the

SET-252 C Programming #2

Homework: 8 Deep copy and more

Continued with your code from homework 7. I recommend you make a copy of the folder/project and keep your homework 7 separate.

Create a protected DeepCopy method.

Create an assignment operator (=) method. Call DeepCopy from this method. Be sure to check for self assignment and to clean up before calling deep copy.

Create a copy constructor. Call Initialize and then the assignment operator.

Overload the subscript [ ] operator. Youll need to make two versions: one regular and one const/const (read only). Use the subscript operator in your code instead of SetValueAt and GetValueAt.

For example: instead of calling clsRA.SetValueAt( 5, 2 ) you would write clsRA[ 2 ] = 5;

Make sure your DeepCopy method uses the subscript operator whenever it needs to get or set a value. The syntax for this is frustrating. Hint: it involves the use of the this self-pointer.

Overload the += operator. Append all the elements in the second array to the end of the first array.

For example: clsRA2 += clsRA1;

void CResizableArray::operator += ( const CResizableArray &clsOriginalToAppend );

Overload the + operator. You should be able to add two arrays together. So if the first array has 3 elements and the second array has 4 elements the result should be an array with 7 elements.

For example: clsRA3 = clsRA1 + clsRA2;

CResizableArray CResizableArray::operator + ( const CResizableArray &clsRight ) const;

The left side is assumed to be the called instance (this). I have 5 lines of code for this procedure including the method signature/declaration but it could easily take an hour to get the corrent syntax.

As always, thoroughly test your code before submitting.

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!