943,640 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 372
  • C++ RSS
Feb 20th, 2009
0

Overloading Of ( ) is possible

Expand Post »
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
Reputation Points: 0
Solved Threads: 1
Light Poster
nitu_thakkar is offline Offline
25 posts
since Jan 2009
Feb 20th, 2009
0

Re: Overloading Of ( ) is possible

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.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
Feb 20th, 2009
0

Re: Overloading Of ( ) is possible

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
Reputation Points: 0
Solved Threads: 1
Light Poster
nitu_thakkar is offline Offline
25 posts
since Jan 2009
Feb 20th, 2009
1

Re: Overloading Of ( ) is possible

When you overload the () operator, it's used as if it were a function call operator and nothing more:
C++ Syntax (Toggle Plain Text)
  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.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Feb 20th, 2009
0

Re: Overloading Of ( ) is possible

yes i aggre whith u but

whould u pls suggest me which kind of operation

is suitable for overloading () as operatore
Reputation Points: 0
Solved Threads: 1
Light Poster
nitu_thakkar is offline Offline
25 posts
since Jan 2009
Feb 20th, 2009
1

Re: Overloading Of ( ) is possible

It sounds disturbingly like you're looking for a problem to fit the solution you recently learned. That's silly.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++ Graphics
Next Thread in C++ Forum Timeline: N digits in word increasing order





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC