Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
operator overload of []
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Bracey  
View profile  
 More options Oct 29 1998, 3:00 am
Newsgroups: borland.public.cppbuilder.language
From: Mark Bracey <red...@interaccess.com>
Date: 1998/10/29
Subject: operator overload of []
I want to overload [] in order to create the equivalent of an indexed
default property (object pascal term)

I have a class which is what I want to index

e.g.

TValue * operator [](int i) {return(TValue*)(FValueList->Items[i]););

FValueList is a TList

But when I try to do the assignment

TValue * Value

Value = List[i];

I get a compile error that 'List' of type TValueList cannot be assigned
to TValue.

What am I doing wrong?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Uzdavinis (TeamB)  
View profile  
 More options Oct 29 1998, 3:00 am
Newsgroups: borland.public.cppbuilder.language
From: "Chris Uzdavinis (TeamB)" <ch...@uzdavinis.com>
Date: 1998/10/29
Subject: Re: operator overload of []

Mark Bracey wrote:
> TValue * operator [](int i) {return(TValue*)(FValueList->Items[i]););

This looks correct.

> Value = List[i];
> What am I doing wrong?

It's just how you're using your list.  Presumably, List is a pointer
to a TList, so what you really need to do is this:

Value = (*List)[i];

...to dereference the pointer, and then call the operator[] on the
object.  

So you know why you got the error... the way you wrote it, your code
was trying to dereference the element number [i] in an array of
TLists.  So the return value of that expression was a TList*, which
didn't match the TValue * type of "Value".  :)
--
Chris (TeamB)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Bracey  
View profile  
 More options Oct 30 1998, 3:00 am
Newsgroups: borland.public.cppbuilder.language
From: Mark Bracey <red...@interaccess.com>
Date: 1998/10/30
Subject: Re: operator overload of []
Thank you very much.  It's been awhile and have spent most of my time on
Delphi as of late.

Thanks again!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google