overloading ->

R

Radde

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..
 
S

Steven T. Hatton

Radde said:
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/
 
A

Alf P. Steinbach

* 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).
 
D

Donovan Rebbechi

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,297
Messages
2,571,536
Members
48,282
Latest member
Xyprime

Latest Threads

Top