Overloading Of ( ) is possible

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jan 2009
Posts: 25
Reputation: nitu_thakkar has a little shameless behaviour in the past 
Solved Threads: 1
nitu_thakkar's Avatar
nitu_thakkar nitu_thakkar is offline Offline
Light Poster

Overloading Of ( ) is possible

 
0
  #1
Feb 20th, 2009
hello everone

i'm new to c++ language

Is This possible to make prg in cpp to overload () Opratore

if yes, then can u pls give any logical flow for develope the prg

i.e. which kind of opeartion can be performed through () opratore

thanx in advance
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,761
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 283
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Overloading Of ( ) is possible

 
0
  #2
Feb 20th, 2009
Are you thinking about using the () as the conversion operator or talking about overloading the () operator to do something like addition or concatenation or some other theoretical possibility?
Last edited by Lerner; Feb 20th, 2009 at 3:43 pm.
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 25
Reputation: nitu_thakkar has a little shameless behaviour in the past 
Solved Threads: 1
nitu_thakkar's Avatar
nitu_thakkar nitu_thakkar is offline Offline
Light Poster

Re: Overloading Of ( ) is possible

 
0
  #3
Feb 20th, 2009
hi......

i have some idea that in overloading of + operatore we can

perform summation or can concate to string

so whould u pls tell me which kind of

operation should i perform for overload the

() as operatore
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Overloading Of ( ) is possible

 
1
  #4
Feb 20th, 2009
When you overload the () operator, it's used as if it were a function call operator and nothing more:
  1. #include <iostream>
  2.  
  3. struct foo {
  4. void operator()()
  5. {
  6. std::cout<<"FOO!\n";
  7. }
  8. };
  9.  
  10. int main()
  11. {
  12. foo bar;
  13.  
  14. bar();
  15. }
If that's not what you want, you're SOL.
Last edited by Narue; Feb 20th, 2009 at 4:09 pm.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 25
Reputation: nitu_thakkar has a little shameless behaviour in the past 
Solved Threads: 1
nitu_thakkar's Avatar
nitu_thakkar nitu_thakkar is offline Offline
Light Poster

Re: Overloading Of ( ) is possible

 
0
  #5
Feb 20th, 2009
yes i aggre whith u but

whould u pls suggest me which kind of operation

is suitable for overloading () as operatore
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Overloading Of ( ) is possible

 
1
  #6
Feb 20th, 2009
It sounds disturbingly like you're looking for a problem to fit the solution you recently learned. That's silly.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 286 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC