Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions