Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > overloading ->

Reply
Thread Tools

overloading ->

 
 
Radde
Guest
Posts: n/a
 
      06-27-2005
HI,
Can we overload -> operator..I hope we can..If so is this to be
member function or global function or global function with that class
as friend..and why it should that??

Cheers..

 
Reply With Quote
 
 
 
 
Steven T. Hatton
Guest
Posts: n/a
 
      06-27-2005
Radde wrote:

> HI,
> Can we overload -> operator..I hope we can..If so is this to be
> member function or global function or global function with that class
> as friend..and why it should that??
>
> Cheers..

You would be well served to visit the FAQ for this newsgroup. To be fair,
your question does not seem to be addressed clearly by the FAQ, so I will
answer it. Yes, you can overload ->. It is done to create things such as
iterators in the Standard Library.
http://www.parashift.com/c++-faq-lite/
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      06-27-2005
* Radde:
> Can we overload -> operator.


Yes.


> If so is this to be member function or global function or
> global function with that class as friend..and why it should that??


'=', '->', '[]' and '()' can only be overloaded as non-static members.

Instead of asking that question that here, you could just put it to
your compiler, which would answer immediately.

Or, check your textbook (you do need a textbook).

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
Donovan Rebbechi
Guest
Posts: n/a
 
      06-27-2005
On 2005-06-27, Radde <> wrote:
> HI,
> Can we overload -> operator..I hope we can..If so is this to be
> member function or global function or global function with that class
> as friend..and why it should that??


Prefer member functions to friend functions. operator-> can be a member so
make it one. I don't know if it can be made a non-member -- all the
implementations I've seen need some access to class internals.

Cheers,
--
Donovan Rebbechi
http://pegasus.rutgers.edu/~elflord/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Overloading __init__ & Function overloading Iyer, Prasad C Python 4 09-30-2005 08:01 PM
Re: Overloading __init__ & Function overloading Fredrik Lundh Python 0 09-30-2005 03:59 PM
Overloading __init__ & Function overloading Iyer, Prasad C Python 3 09-30-2005 02:17 PM
Re: Overloading __init__ & Function overloading Steve Holden Python 0 09-30-2005 01:58 PM
Re: Overloading __init__ & Function overloading Fredrik Lundh Python 0 09-30-2005 01:53 PM



Advertisments