I have little problem but i don't know how to fix it. I wanted to test the friend function for the first time but I got error:
|17|error: 'minutes' was not declared in this scope|
|18|error: 'hours' was not declared in this scope|
|24|error: 'minutes' was not declared in this scope|
|24|error: 'minutes' was not declared in this scope|
That is my all code:
#include <iostream>
using namespace std;
class Time
{
int hours;
int minutes;
friend Time operator+(const Time & t);
friend void x(Time h, Time m );
};
Time operator+(const Time & t)
{
Time sum;
sum.minutes = minutes + t.minutes;
sum.hours = hours + t.hours + sum.minutes / 60;
sum.minutes %= 60;
return sum;
}
void x(Time h, Time m) {hours = h; minutes = m;}
Aucun commentaire:
Enregistrer un commentaire