please consider following code
#include <iostream>
using namespace std;
class Digit
{
private:
int m_digit;
public:
Digit(int ndigit=0){
m_digit=ndigit;
}
Digit& operator++();//prefix
Digit& operator--(); //prefix
Digit operator++(int);
Digit operator--(int);
int get() const { return m_digit;}
};
Digit& Digit::operator++(){
++m_digit;
return *this;
}
Digit& Digit::operator--(){
--m_digit;
return *this;
}
Digit Digit::operator++(int){
Digit cresult(m_digit);
++(*this);
return cresult;
}
Digit Digit::operator--(int){
Digit cresult(m_digit);
--(*this);
return cresult;
}
int main(){
Digit cDigit(5);
++cDigit;
cDigit++;
cout<<cDigit.get()<<endl;
cout<<cDigit.get()<<endl;
return 0;
}
here is implemented two version of postfix and prefix operators,i have read that difference is made by introduce another so called dummy argument,but i have question if we see declaration of these
Digit& operator++();//prefix
Digit& operator--(); //prefix
Digit operator++(int);
Digit operator--(int);
they are differed by & mark,so why it is necessary dummy argument?and also in both case for example ++ operator is written before the argument and does not it means that they are same?