There are two important ways to create array of arrays in C++ programming language. The first one is using two-dimensional array and the latter is using pointer and new operator. For the first way visit C++ 2D array.
In the second way by using pointer, new and delete operators, we can create array of arrays with better memory management because memory is allocated and released dynamically.
using namespace std;
int fd=3;//number of elements in the upper array
int sd=5;//number of elements in the lower array
int **arr=(int**) new int*[sd]; //allocate upper level array
arr[i]=new int[sd];//allocate the lower level arrays
//The first array contains three elements and each element
//contains five elements.
//assign 0 values to array elements
//loop through the array-print array
Posted by: ly | post date: 01-27-2013 | Subject: C++ Programming Language
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: