Ok, this may seem like a stupid question, but... it just doesn't make sense to me...
even when looking at the MSDN site and through my C++ textbooks...
here's the sample code i am having problems grasping the logic....
now... if index is an array.. there can be index[0] and index[1]... right?
and PutElement is a function to put a value (in this case "val" into an array (in this case "saRet"... right?
and the first value is to be the index of the saRet array... right?
so, how does this function determine whether the value of index[0] or the value of index[1] is the proper index for this function?
OR.. is it because saRet is a 2 dimensional array.. that BOTH values of index (index[0] and index[1]) are used to find a place in saRet?
thanks in advance...
Lars.
even when looking at the MSDN site and through my C++ textbooks...
here's the sample code i am having problems grasping the logic....
Code:
VARIANT _stdcall retVariantArray(void)
{
COleSafeArray saRet;
DWORD numElements[] = {10, 10}; // 10x10
// Create the 2 dimensional safe-array of type VT_R8 with size 10x10
saRet.Create(VT_R8, 2, numElements);
// Initialize safearray with values...
long index[2];
for(index[0]=0; index[0]<10; index[0]++)
{
for(index[1]=0; index[1]<10; index[1]++)
{
double val = index[0] + index[1]*10;
//populate the safearray elements with double values
saRet.PutElement(index, &val);
}
}
// Return the safe-array encapsulated in a VARIANT...
return saRet.Detach();
}
now... if index is an array.. there can be index[0] and index[1]... right?
and PutElement is a function to put a value (in this case "val" into an array (in this case "saRet"... right?
and the first value is to be the index of the saRet array... right?
so, how does this function determine whether the value of index[0] or the value of index[1] is the proper index for this function?
OR.. is it because saRet is a 2 dimensional array.. that BOTH values of index (index[0] and index[1]) are used to find a place in saRet?
thanks in advance...
Lars.