implementation differences between ++i and i++

I create a class: Cl and i create an instance of it: temp_c.
I want to overide the two operators so that ++temp_c and temp_c++ will be a valid code.
1. can you give me the signatures of the two methods?
2. Is there a difference between the implementations of both operators? (I ask this because in ++temp_c, temp_c is first increased and in temp_c++ is increased only after the operation is done.
Thank you!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


There is only one operator called operator++ and it is called for both cases.

Cl* Cl::operator++()
  // Do something.
  return this;

(I ask this because in ++temp_c, temp_c is first increased and in temp_c++ is increased only after the operation is done. )

This is almost true.  The word increased shouldn't be there because if you override the operator it might do something else.

a = temp++;

a is first assigned the value of temp then the operator++ is called and it might do something else.

But for

a = ++temp;

The operator is called first and then a is assigned the value of temp.

Hope this explains things
>> There is only one operator called operator++
>> and it is called for both cases.
That is not true.  You may overide both the pre-increment and the post-increment operators seperately.
The postfix form of operator++ (i++) takes an extra parameter, and int, that is not passed to the prefix form( ++i).  This int will always be passed as 0 and just serves to differentiate the two forms.  
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

1) there are two different operators for that with different signatures.
2) they (can) have different implementations

post-increment (i++)
   Cl  Cl::operator++(int)
           {Cl tmp(*this); ++(*this); return temp;}

pre-increment (++i)
   Cl& Cl::operator++()
           {this->do_increment(); return *this;}
I mean the proposed answer is wrong.
rzvika3Author Commented:
KangaRoo, take the point and thank you all!
Ok, thanx!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rzvika3Author Commented:
You are welcome!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.