Funkcja przyjmująca jako parametry referencję do struktury

0

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;
}
1

W dużym uproszczeniu, błąd mówi, że brakuje implementacji metody differenceTime.
Zauważ, że deklaracja:

 
struct time differenceTime(struct time&, struct time&);

różni się od nagłówka definicji:

 
inline struct time differentTime(struct time& a, struct time& b)

Po prostu raz piszesz differenceTime, a raz differentTime - literówka?

0

BTW w C++ nie ma sensu powtarzać słowa struct

struct time differenceTime(struct time&, struct time&);
void print(const struct time&);

wystarczy

void print(const time&);

Tak samo brzydka jest deklaracja zmiennych przy deklaracji struktury

} measurement, sleepTime, oldSleepTime, newSleepTimeDifference, sleepTimeDifference;
0

Powtarzanie struct mi zostalo z C.
A funkcja rzeczywiscie miala literowke xD

EDIT: Czy ktoś mi powie jak ominąć to słowo kluczowe struct? Próbuje na różne sposoby, ale nie moge dać rady :D Uzywam code::blocks z compilatorem GNU GCC Compiler, jeśli to ma jakieś znaczenie. Program napisany w C++

1 użytkowników online, w tym zalogowanych: 0, gości: 1