Question: The class B is responsible for a an array of ints on the heap. Write a copy constructor that does a deep copy of a

 The class B is responsible for a an array of ints

The class B is responsible for a an array of ints on the heap. Write a copy constructor that does a deep copy of a B object. Hint: You need to make your own array on the heap and then copy each int over from the other object's array to your array with a loop. Code 1 #include 3 using namespace std; 5 class B t 6 public: 7 B(int numValues, int start) ( size = numvalues ; //allocate an array on heap myArray new intnumValues 10 12 13 14 15 16 //Do not modify anything on or above the line below this 17 /YOUR CODE BELOW 18 19 20 21 /YOUR CODE ABOVE 22 //Do not modify anything on or below the line above this 23 24void print) 25 26 27 28 29 0 public: //variables public for simplicity of testing code in main - don't try this at home 31 32 33i 34 35 int main) for(inti-o: i

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!