Hi Kat, I’m learning c++ so all this is new to me, and if you can do this with vectors then you know more than me.

However, if you’re still stuck, then Salem’s perfectly presented code above is intuitively very simple.

“One of the main usages of a pointers is for heap memory allocation. The benefit of heap allocation is that you manage when the data is created, how long it exists, and the size is defined at run-time.”

“In C++ use the new (data type)[ [size of elements] ] keyword to allocate data. Note that unlike the C function malloc(), the new keyword allocates sizes by calculating the needed bytes itself. Use the delete keyword to release data. Do not forget to use the delete[] keyword when releasing an array of data.”


So, for a one-dimensional array:

Code:
float *WeightTable;
int x = 10;  
WeightTable = new float[x];

//Testing
WeightTable[0] = 1.234;
WeightTable[9] = 5.678;
cout << WeightTable[0] << endl; //prints 1.234
cout << WeightTable[9] << endl; //prints 5.678

delete WeightTable; // clear memory
And for a two dimensional array:

Code:
float **WeightArray; 
int Rows;
int Cols;

Rows = 8;
Cols = 9;

WeightArray = new float*[Rows];
for (int i = 0; i < Rows; i++) 
	WeightArray[i] = new float[Cols];

// Testing
WeightArray[0][0] = 1.234;
WeightArray[7][8] = 5.678;
cout << WeightArray[0][0] << endl;
cout << WeightArray[7][8] << endl;


// loop to delete WeightArray[Rows][Cols]
Intuitive note:

For 1D array there is one *, and after the new keyword there are no *’s.

For a 2D array there are 2 *’s, and after the new keyword there is one *, and no *’s after the second occurrence of the new keyword