operator overloading



 DEVELOP > c-Plus-Plus > operator overloading

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "mangesh"
Date: 29 Aug 2006 03:33:59 AM
Object: operator overloading
I have a list implementation in which [] operator has been ocerloaded .
Now when i have pointer to list say *list_ptr , and i write
list_ptr[0] .
Which [] operator will be called ?
Overloaded or default ?
I think default [] , but in may case i am not getting result
accordingly .
Regards ,
Mangesh Sawant .
.

User: "Michal Nazarewicz"

Title: Re: operator overloading 29 Aug 2006 04:28:39 AM
"mangesh" <mangesh_sawant@walla.com> writes:

I have a list implementation in which [] operator has been ocerloaded .
Now when i have pointer to list say *list_ptr , and i write
list_ptr[0] .
Which [] operator will be called ?
Overloaded or default ?

The default, because you have only overloaded [] for type Foo (where
Foo is you list class) and *not* for Foo* (which in fact is impossible
as Foo* is /built-in/ type). To use overloaded [] you have to do:
(*list_ptr)[0].
--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
.

User: "Ye Dafeng"

Title: Re: operator overloading 29 Aug 2006 03:55:44 AM
mangesh wrote:

I have a list implementation in which [] operator has been ocerloaded .
Now when i have pointer to list say *list_ptr , and i write
list_ptr[0] .
Which [] operator will be called ?
Overloaded or default ?
I think default [] , but in may case i am not getting result
accordingly .

Regards ,
Mangesh Sawant .

i think it uses the overloaded one
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER