Hi,
I created a small Class that gets 1 time (format: 00:00) and minuses it from another time (same format).
This is the member function I had:
void sub(airtime t1, airtime t2)
{
int min1 = t1.hours * 60 + t1.minutes;
int min2 = t2.hours * 60 + t2.minutes;
int answer = min1 - min2;
hours = answer / 60;
minutes = answer - hours * 60;
}
At first, when I was entering certain numbers, it was crashing ( continuosly looping).
Then I changed:
int min1 = t1.hours * 60 + t1.minutes;
int min2 = t2.hours * 60 + t2.minutes;
to:
int min1 = (t1.hours * 60) + t1.minutes;
int min2 = (t2.hours * 60) + t2.minutes;
It worked perfectly when I edited the above code.
However, I still do not know what change it might have made.
I thought that in C++, the * is automatically worked before the +, so why did I need those brackets?
Thanks!
Marc