Witam.
Mam problem, ponieważ dostaje 3 komunikaty od kompilatora undefined reference to 'differenceTime(time&, time&)'
Nie wiem o co chodzi
#include <iostream>
#include <string>
using namespace std;
struct time
{
unsigned short s, m, h;
string status;
} measurement, sleepTime, oldSleepTime, newSleepTimeDifference, sleepTimeDifference;
struct time differenceTime(struct time&, struct time&);
bool isMoreTime(struct time&, struct time&);
void print(const struct time&);
int main()
{
ios_base::sync_with_stdio(0);
int howManyTests, howManyTimes;
char c;
cin>>howManyTests;
while(howManyTests--)
{
cin>>howManyTimes;
cin>>sleepTime.h>>c>>sleepTime.m>>c>>sleepTime.s;
sleepTimeDifference = sleepTime;
oldSleepTime.h = 9; oldSleepTime.m, oldSleepTime.s = 0; // poczatek zawodow programistycznych
for(int i = 0; i < howManyTimes; ++i)
{
cin>>measurement.h>>c>>measurement.m>>c>>measurement.s>>measurement.status;
if(measurement.status == "AC")
{
newSleepTimeDifference = differenceTime(oldSleepTime, measurement);
if(isMoreTime(newSleepTimeDifference, sleepTimeDifference))
sleepTimeDifference = newSleepTimeDifference;
}
}
measurement.h = 14; measurement.m, measurement.s = 0; // koniec zawodow programistycznych
newSleepTimeDifference = differenceTime(oldSleepTime, measurement);
if(isMoreTime(newSleepTimeDifference, sleepTimeDifference))
sleepTimeDifference = newSleepTimeDifference;
if(!isMoreTime(sleepTime, sleepTimeDifference)) cout<<0<<endl;
else print(differenceTime(sleepTime, sleepTimeDifference));
}
return 0;
}
inline struct time differentTime(struct time& a, struct time& b) // zwraca roznice czasu pomiedzy kolejnymi AC
{
struct time newTime;
if(a.s > b.s)
{
if(b.m) --b.m;
else
{
--b.h;
b.m = 59;
}
b.s += 60;
newTime.s = b.s - a.s;
}
else newTime.s = b.s - a.s;
if(a.m > b.m)
{
if(b.h) --b.h;
b.m += 60;
newTime.m = b.m - a.m;
}
else newTime.m = b.m - a.m;
newTime.h = b.h - a.h;
return newTime;
};
inline bool isMoreTime(struct time& a, struct time& b) // sprawdza czy roznica pierwszego czasu jest wieksza niz drugiego
{
if(a.h > b.h) return true;
else if(a.h < b.h) return false;
if(a.m > b.m) return true;
else if(a.m < b.m) return false;
if(a.s > b.s) return true;
else return false;
};
inline void print(const struct time& a) // drukuje czas drzemnki
{
if(a.h < 10) cout<<0<<a.h<<":";
else cout<<a.h<<":";
if(a.m < 10) cout<<0<<a.m<<":";
else cout<<a.m<<":";
if(a.s < 10) cout<<0<<a.s<<endl;
else cout<<a.s<<endl;
}