473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

cannot perform pointer arithmetic

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 *'


Nov 17 '05 #1
3 1506
<sadun> wrote:
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.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #2
thanks for information...

there is a method exists for SortedList

this->query->SList->GetByIndex(this->listBox1->SelectedIndex);
Nov 17 '05 #3
<sadun> wrote:
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.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: overbored | last post by:
I can do this: int asdf; int* zxcv = asdf; but not this: int asdf; int** zxcv = asdf;
8
by: ceo | last post by:
Hi, Following is a program that doesn't give the expected output, not sure what's wrong here. I'm adding the size of derived class to the base class pointer to access the next element in the...
22
by: Alex Fraser | last post by:
From searching Google Groups, I understand that void pointer arithmetic is a constraint violation, which is understandable. However, generic functions like qsort() and bsearch() must in essence do...
3
by: randomtalk | last post by:
hello everyone! Well, recently i've been trying to pick up c and see what is pointer all about (been programming in lisp/python for the better part of my last two years).. mmm.. I'm currently...
7
by: barikat | last post by:
int a; int *Ptr1, *Ptr2; Ptr1 = a; Ptr1++; Ptr2 = a; printf("Ptr1 : %p\n", Ptr1); printf("Ptr2 : %p\n\n", Ptr2);
26
by: Bill Reid | last post by:
Bear with me, as I am not a "professional" programmer, but I was working on part of program that reads parts of four text files into a buffer which I re-allocate the size as I read each file. I...
5
by: Mercy | last post by:
I guess my C++ is pretty darn rusty. I was just looking over sample C++ code for practice... and I'm kind of confused about this code fragment: int sector2; int i = 3; memset(sector2,...
19
by: =?iso-8859-1?b?VG9t4XMg0yBoyWlsaWRoZQ==?= | last post by:
Coming originally from C++, I used to do the likes of the following, using a pointer in a conditional: void Func(int *p) { if (p) { *p++ = 7; *p++ = 8;
25
by: Ioannis Vranos | last post by:
Are the following codes guaranteed to work always? 1. #include <iostream> inline void some_func(int *p, const std::size_t SIZE) {
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.