Question: A class newType is defined as in the following program. Complete the program by: in the constructor, use the pointer p to dynamically allocate an
A class newType is defined as in the following program. Complete the program by: in the constructor, use the pointer p to dynamically allocate an array with 10 integers, assign the array with random numbers within [0, 20]. The member function fun() requires an integer parameter n, the function calculates and returns the product of all odd numbers in the array that are greater than n; deallocates the array in the destructor. In main(), use newType to declare a variable and call its fun() to print the product (while calling the function, pass an integer less than 10). #include using namespace std; class newType//Part I class definition { private: int *p; public: newType(); ~newType()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
