G
Guest
Is this a bug in the for each loop or am I coding something wrong (or is this
how its suppose to function and I don't understand how an array property and
the for each interact [this is always a possibility ]
The commented out code is the problem area as it generates the error:
->for each statement cannot operate on variables of type 'overloaded-function'
using namespace System;
ref class ArrayProp
{
public:
ArrayProp(int size)
{
numArray = gcnew array<int>(size);
}
property array<int>^ NumArray
{
array<int>^ get()
{
return numArray;
}
void set ( array<int>^ value )
{
numArray = value;
}
}
private:
array<int>^ numArray;
};
void main()
{
ArrayProp aprop(5);
for ( int i = 0 ; i < aprop.NumArray->Count ; ++i )
aprop.NumArray = i;
for ( int i = 0 ; i < aprop.NumArray->Count ; ++i )
Console::WriteLine(aprop.NumArray);
// for each (int i in aprop.NumArray)
// {
// Console::WriteLine(i);
// }
}
how its suppose to function and I don't understand how an array property and
the for each interact [this is always a possibility ]
The commented out code is the problem area as it generates the error:
->for each statement cannot operate on variables of type 'overloaded-function'
using namespace System;
ref class ArrayProp
{
public:
ArrayProp(int size)
{
numArray = gcnew array<int>(size);
}
property array<int>^ NumArray
{
array<int>^ get()
{
return numArray;
}
void set ( array<int>^ value )
{
numArray = value;
}
}
private:
array<int>^ numArray;
};
void main()
{
ArrayProp aprop(5);
for ( int i = 0 ; i < aprop.NumArray->Count ; ++i )
aprop.NumArray = i;
for ( int i = 0 ; i < aprop.NumArray->Count ; ++i )
Console::WriteLine(aprop.NumArray);
// for each (int i in aprop.NumArray)
// {
// Console::WriteLine(i);
// }
}