Do it have a priority in overloading operator

I'm foreigner. I'm not good at English. Can someone explain somewhere in this code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  
      Time operator++( int )         
      {
         // save the orignal value
         Time T(hours, minutes);  // I don't know why there is a constructor in here
         // increment this object
         ++minutes;                    
         if(minutes >= 60)
         {
            ++hours;
            minutes -= 60;
         }
         // return old original value
         return T; 
      }

And in class Time, I have assignment operator overloading
1
2
3
4
5
Time& operator=(Time T1)
      {
           this->hours=T1.hours;
           this->minutes=T1.minutes;          
      }

in main fucntion
1
2
3
4
5
void main()
{
    Time T1(40,50),T2(20,20),T;
    int x=5,y=6;
}

"T=T1++" is the same as "x=y++"
Someone can explain for me? Thanks all so much!
 
x = y++;

This has the same effect as
1
2
x = y;
y = y + 1;


The x is given the value of y before it is changed.

In the same way here Time operator++( int ), a copy of the original value is saved and returned at the end.
The first looks like post-increment operator. Do you know what post-increment operator does?
Topic archived. No new replies allowed.