Linker Fehler in Klasse



  • Ich finde den Fehler nicht. Kann mir einer helfen?

    Header:

    #ifndef _DAYTIME_
    #define _DAYTIME_
    #include <iostream> 
    using namespace std;
    
    class DayTime
    {
          private:
                  short hour, minute, second;
                  bool overflow;
          public:
                 DayTime( int h = 0, int m = 0, int s = 0 );
                 bool setTime(int hour, int minute, int second = 0);
                 int getHour() const {return hour;}
                 int getMinute() const {return minute;}
                 int getSecond() const {return second;}
    
                 int asSeconds() const //Tageszeit als Sekunden
                 {
                     return (60*60*hour + 60*minute + second);
                 }
                 bool operator<( const DayTime& t) const
                 {                                 // *this mit t vergl.
                      return asSeconds() < t.asSeconds();
                 }
                 DayTime& operator++()                   // Sekunden erhöhen
                 {
                          ++second;
                          return *this;
                 }
                 void print () const;
    
          };
    #endif //_DAYTIME_
    

    CPP Datei:

    #include "DayTime.h"
    
    int main()
    {
    DayTime abflug1(11,11,11), abflug2(12,0,0);
    if(abflug1 < abflug2)
    cout << "1. früher" << endl;
    cin.get();
    }
    

    Fehler:

    [Linker error] undefined reference to `DayTime::DayTime(int, int, int)'
    

  • Administrator

    Du hast den Konstruktor Daytime(int, int, int) nicht definiert. Ist auch in deinem gezeigten Code nicht vorhanden. Aber das sollte auch aus der Fehlermeldung mehr als deutlich hervorgehen.

    Grüssli


Anmelden zum Antworten