;) Hello ladies and gents,
Ive written this class time in wich I have to use operator+ to increase the hour with a certain amount of minutes like this:
time t0 (23, 59), t1; // t0 = 23.59
t1 = t1 + 120; // t1 = 1.59
Problem is, I can't get those 120 minutes into the operator+ :confused:
I know that the calculation part isn't correct yet, but I'll sort that out later, I first want to be able to get those 120 minutes into the class :!:
Please, do not give the solution as to how I should do the calculation, ONLY how I can get those 120 minutes into the class ;)
This is the program Ive written sofar,
class time
{
public:
time (int uren = 0, int minuten = 0) : hours (uren), minutes (minuten) {}
time operator+ (const time &a)
{
while (a.minutes > 0)
{
if (minutes >= 60)
{
minutes = a.minutes - 60;
hours += 1;
}
else
minutes +=minutes;
}
return (hours, minutes);
}
void print()const
{
cout<< "The time is now: " << hours << "Hr " << minutes << "." <<endl;
}
private:
int hours, minutes;
};
int main()
{
time t0(23, 59), t1;
t0.print();
t1 = t0 + 120;
t1.print();
return 0;
}
Thanks for the assistance ;)