A 1D array stored in memory sequentially, starting with the zeroth element, in a contiguous block of memory. The allocated array is then referenced using a pointer that points to the first data element. Character arrays are a great place to start experimenting – see the Fundamentals :: Char Arrays page.

const int arrayLength = 3;	                //tell the compiler that this variable cannot change
					                        //allocate on the stack
int array1[arrayLength] = { 5, 8, 2 };	//length must be known at time of compile

Stack vs. Heap: simply put the Stack is managed by the compiler and its use can be optimized because the memory requirements can be known ahead of time. The Heap is a memory space that is allocated and deallocated by the programmer as needed; called dynamic memory, the size does not have to be known ahead of time.

int* array2 = NULL;					//create a pointer to be used to reference interger array
								//allocate memory on the heap for an array of 100 intergers
array2 = new int[100];				//the values will all be zero by default
array2[3] = 55;						//set the value of the third element to 55
								//get the size in bytes of an interger
								//multiply by 5 and add the result to the address of the first element of array2
*(array2 + 5 * sizeof(int)) = 67;		//dereference the resulting address and set its value to 67 (5th element)
delete[] array2;					//delete contents of heap - does not delete pointer
array2 = NULL;					//set pointer value to NULLwn at time of compilenter value to NULL

If a 1D array is a block of memory referenced by the address of its first element, then a 2D array is an array of pointers each of which points to the first element of a corresponding block of memory.

int myArray[4][3] = {	{1,2,3},	//allocate and set values
					{0,1,2} };
myArray[3][1] = 15;				//change value
int myInt = myArray[2][1];		//access values

int** myArray2 = new int*[50];	//allocate array of pointers on heap
for (int i = 0; i < 50; i++) {
	myArray2[i] = new int[30];
myArray2[46][29] = 15;			//set value
for (int i = 0; i < 50; i++) {		//delete each int array
	delete[] myArray2[i];
	myArray2[i] = NULL;
delete[] myArray2;				//delete array of pointers
myArray2 = NULL;				//set myArray to NULL

Because each dimension beyond the first is just a list of references, there is no geometric equivalent and therefore is not limited a finite number of dimensions.