Groups | Blog | Home
all groups > visual c > april 2004 >

visual c : cannot perform pointer arithmetic


Doug Harrison [MVP]
4/18/2004 8:56:30 PM
[quoted text, click to view]

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.

--
Doug Harrison
<sadun>
4/19/2004 2:46:38 AM
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 *'



<sadun>
4/19/2004 9:41:57 AM
thanks for information...

there is a method exists for SortedList

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

Doug Harrison [MVP]
4/19/2004 10:46:22 AM
[quoted text, click to view]

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.

--
Doug Harrison
AddThis Social Bookmark Button