cannot perform pointer arithmetic

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

this->user_information->Text =
this->query->SList[this->listBox1->SelectedIndex];

sList is a SortedList i want to reach its valur by its index ??? i got this
error


error C2845: '[' : cannot perform pointer arithmetic on __gc pointer
'System::Collections::SortedList __gc *'
 
this->user_information->Text =
this->query->SList[this->listBox1->SelectedIndex];

sList is a SortedList i want to reach its valur by its index ??? i got this
error


error C2845: '[' : cannot perform pointer arithmetic on __gc pointer
'System::Collections::SortedList __gc *'

Try using the Item method, e.g.

a->Item[n];

The problem is that the current incarnation of Managed C++ represents
objects of reference types as pointers, for which operator[] already has a
meaning in C++. Though it's disallowed for managed pointers, it's still part
of the language, hence the error message. Unfortunately, this messiness
means Managed C++ currently doesn't support the nice indexer syntax you have
in other languages. This problem is addressed in the upcoming Whidbey
compiler, which provides many improvements in the Managed C++ syntax.
 
thanks for information...

there is a method exists for SortedList

this->query->SList->GetByIndex(this->listBox1->SelectedIndex);
 
thanks for information...

there is a method exists for SortedList

this->query->SList->GetByIndex(this->listBox1->SelectedIndex);

Yep, that seems to be what you needed. The indexer and Item property take a
key to look up as their argument and return the associated value for
SortedList.
 
Back
Top