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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started