Question: C++ Language Implement a function with the prototype below: int * makeArray(int theSize, int init = 0); The function should return a dynamically allocated array

C++ Language

Implement a function with the prototype below:

int * makeArray(int theSize, int init = 0);

The function should return a dynamically allocated array with all elements initialzed to the value init. Notice that init has a default value of 0. That's so that the function can be called without a second argument, if desired.

The function should also check for illegal values for theSize. If the client calls makeArray with a negative or zero value for theSize then the function should just return an array allocated with size 1.

Please provide code for both whole program and just function.

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!