Question: C++ Program Create a function that returns a pointer to a 2 dimensional dynamic array of integer elements. The function should have 2 parameters that

C++ Program

Create a function that returns a pointer to a 2 dimensional dynamic array of integer elements. The function should have 2 parameters that correspond to the size of each of the dimensions.

Use the function in a program that lets the user decide how large the array is and then deletes the array.

Here's my code so far:

#include using namespace std;

typedef int* IntPointer;

int* arrayReturnFunction(); IntPointer *array();

int main() { int index1Size, index2Size; cout << "Array size 1: "; cin >> index1Size; cout << "Array size 2: "; cin >> index2Size;

IntPointer *dynamicArray;

dynamicArray = new IntPointer[index1Size];

for (int i = 0; i < index2Size; i++) { dynamicArray[i] = new int[index2Size]; }

int* p; p = arrayReturnFunction(); p[3];

//delete[] dynamicArray;

return 0; }

int * arrayReturnFunction() { int* arr = new int[5]; return arr; }

IntPointer * array() { }

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!