Array manipulation

I just got introduced to VC++ 2005, and since I deal a lot with matrices, I'm trying to write a few functions to help me. However, the following code to view the sum of a matrix is giving an error when compiling

void SumArray(Array^ myArr)
{
int total = 0;
for(int i=0;i<myArr->GetLength(0);i++)
for(int j=0;j<myArr->GetLength(1);j++)
total += myArr[i,j];


Console::WriteLine(total);
}


error C2039: 'default' : is not a member of 'System::Array'
c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : see declaration of 'System::Array'

Any help on this
Also, are there already builtin functions that I can use on arrays/matrices

Thanks


Answer this question

Array manipulation

  • H_Innocent

    Although all managed arrays inherit from System.Array, you don’t normally use it directly and instead use the “array” keyword. It allows you to declare a strongly-type array including the number of dimensions. Change the function argument as follows and it should work:

    void SumArray(array<int, 2>^ myArr);

    Cheers,
    Kenny Kerr

    http://weblogs.asp.net/kennykerr/


  • Array manipulation