did u ever bother your self on how to make 3D array where second and third dimension will be of different size?
well here is an example on how to do that.
if you take a brief look you may conclude that, it's possible to create no matter how many different sized dimensions!
(the most important part of code is commented)
#include <iostream>
usingnamespace std;
int main() {
int first, second, third;
cout << "enter first dimension for MASTER->";
cin >> first;
int*** master = newint**[first];
for(int i = 0; i < first; ++i) {
cout << "enter second dimension for MASTER->" << i+1 << " dimension?:";
cin >> second;
master[i] = newint*[second];
for(int j = 0; j < second; ++j) {
cout << "enter third dimension for MASTER->" << i+1 << "->" << j+1 << " dimension?:";
cin >> third;
++++third; //incrase third dimension to store data about dimension length's
master[i][j] = newint[third];
master[i][j][0] = second; //hold the value of second dimension
master[i][j][1] = third; //hold the value of third dimensioNS for current second dimension.
for(int k = 2; k < third; ++k)
master[i][j][k] = 0; //initialize all the values to whatever
}
}
cout << "\nlist of members:\n";
for(int i = 0; i < first; ++i)
for(int j = 0, sec = master[i][j][0]; j < sec; ++j) //second dimension is not always the same!!
for(int k = 2; k < master[i][j][1]; ++k) //third dimension is not always the same as well!!
cout << "MASTER->" << i+1 << "->" << j+1 << "->" << k-1 << ". member-> " << master[i][j][k] << endl;
for(int i = 0; i < first; ++i) {
for(int j = 0, sec = master[i][j][0]; j < sec; ++j) //second dimension is not always the same!!
delete [] master[i][j];
delete [] master[i];
}
delete [] master; // now it's time to kill last standing pointer
return 0;
}