1)
PtrArray<Array<int.*> ptrArray1(0,10)
how do I interprete the above?
2)DynamicArray<MString> MStringArray1(10, "foo");
if the Array1 is of Mstring why it can initialized with integer of 10?
This does not appear to be correct. 1) there is only one > and two <. 2) int.* is not a type. Do you mean PtrArray<Array<int*> > ptrArray1(0, 10);lilzz wrote:1)
PtrArray<Array<int.*> ptrArray1(0,10)
how do I interprete the above?
In your code snippet MStringArray1 (there is no variable Array1) is a DynamicArray<> of type Mstring. MStringArray(10, "foo") initializes the DynamicArray<MString> class and so calls the constructor of that (DynamicArray<MString>) class. I suspect given the name DynamicArray it can grow dynamically, but you can specify an initial size in the constructor. so MStringArray(10, "foo") will be initialized to hold 10 MString objects and each of these objects will be initialized with the value "foo".lilzz wrote:2)DynamicArray<MString> MStringArray1(10, "foo");
if the Array1 is of Mstring why it can initialized with integer of 10?
OK, it's not a 2-dimensional array? Like below the ranNums with two numbers indicates the size of the 2-d array.AndyD wrote: 2)DynamicArray<MString> MStringArray1(10, "foo");
if the Array1 is of Mstring why it can initialized with integer of 10?
In your code snippet MStringArray1 (there is no variable Array1) is a DynamicArray<> of type Mstring. MStringArray(10, "foo") initializes the DynamicArray<MString> class and so calls the constructor of that (DynamicArray<MString>) class. I suspect given the name DynamicArray it can grow dynamically, but you can specify an initial size in the constructor. so MStringArray(10, "foo") will be initialized to hold 10 MString objects and each of these objects will be initialized with the value "foo".
Code: Select all
Array<MRandom> ranGens(10);
Array2<int> ranNums(10, 101); // ranNums[i][j] stores the j-th random
// number produced by the i-th generator.
// ranNums[i][0] stores how many random
// numbers have been generated so far.
for (int i=0; i<10; i++) {
ranGens[i].init(SEED3);
ranNums(i, 0) = 0;
}
Probably not, but I can only guess the functionality of a template from a small snippet of code!lilzz wrote:OK, it's not a 2-dimensional array? Like below the ranNums with two numbers indicates the size of the 2-d array.
Each of these templates are different. Again, it would be nice to have some information about this code as a whole. It is very hard to give you any useful information from these snippets!lilzz wrote:Code: Select all
Array<MRandom> ranGens(10); Array2<int> ranNums(10, 101); // ranNums[i][j] stores the j-th random // number produced by the i-th generator. // ranNums[i][0] stores how many random // numbers have been generated so far. for (int i=0; i<10; i++) { ranGens[i].init(SEED3); ranNums(i, 0) = 0; }