Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please make the code based on C++, and add descriptions for each code. Given the following code: Write a client to produce the following output:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedPlease make the code based on C++, and add descriptions for each code.

Given the following code: Write a client to produce the following output: 00 1 10 2 20 3 30 4 40 5 50 6 60 7 70 8 80 9 90 copyfrom is called Printing the new copied array 00 1 10 2 20 3 30 440 5 50 6 60 7 70 8 80 9.90 Store - invalid index: 11 ValueAt - invalid index: 11 Initialization Copy constructor is called Pass by copy Copy constructor is called Return by copy Copy constructor is called I/dynamic9.h class pynancay public DynArray( in int arrsize ) Constructor Y PRE arsize is assigned POST: TIE SIZE = 1.88 enough teary THEN Array 0 size site is created with lealents ELSE Toressages DynArray( const DynArray& otherare); copy constructor IT POST Ithis DynArray is a deep copy of other It is splicitly called for inalization DynArray Destructor IZ POST: Memory fon dynamic array deallocated! int ValueAt (in Mint 1 ) const; PRE! 15 assigned POSTE LE BRI size of this chay THEN FETVAL 1 Value of array element at index ELSE erron message. void Store PRE POS in int val, int 1 DI val and are assigned 19 @ include DynArray: :DynArray(10 Yint arrSize ) 1/ Constructor IL PREO arrsize is assigned H/POST: If arrsize >= 1 && enough memory THEN Acray of size arrsize is created with elements B ELSE error message. { all int i; If ( arrSize = size ) { std::cerr = size ) { std::cerr "valuest - invalid index : - 1 // Creates a deep copy of otherine. 1 POST: Array pointed to by arrentry deallocated && IR room on free store // THEN new array is created on free store && arr - Its base address && size == otherArr.size && arr[e.size-1) == otherarr[e..size-1] ELSE halts with error message. int 1; delete() arr; I delete current array size = otherArr.size; are = new int [size]; // allocate new array for (i = 0; i using namespace std

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

what are the provisions in the absence of Partnership Deed?

Answered: 1 week ago

Question

1. What is called precipitation?

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago