Mein Compiler gibt folgende Meldung aus...
duration.hh:59: Fehler: expected constructor, destructor, or type conversion before »&« token
duration.hh:60: Fehler: expected constructor, destructor, or type conversion before »&« token
duration.cc:57: Fehler: expected constructor, destructor, or type conversion before »&« token
duration.cc:63: Fehler: expected constructor, destructor, or type conversion before »&« token
Meine Header Datei (duration.hh)
#ifndef DURATION_HH
#define DURATION_HH
class Duration{
...unwichtig ;-)
};
// E/A Operatoren
ostream& operator<<(ostream& outStream, Duration value); // Das ist Zeile 59
istream& operator>>(istream& inStream, Duration& duration); // Das ist Zeile 60
#endif
Und die Definition (duration.cc)
const char IO_SEPERATOR = ';';
ostream& operator<<(ostream& outStream, Duration value){ //Zeile 57
outStream << value.hours() << IO_SEPERATOR
<< value.minutes() << IO_SEPERATOR
<< value.seconds();
return outStream;
}
istream& operator>>(istream& inStream, Duration& duration){ //Zeile 63
int hours;
int minutes;
int seconds;
char seperator;
inStream >> hours >> seperator
>> minutes >> seperator
>> seconds;
duration = Duration(hours, minutes, seconds);
return inStream;
}
Wieso kann ich den Operator nicht überladen? ... Seht ihr i-wo einen Fehler?
Das überladen von operator+ und operator- klappt wunderbar, aber hier bekomme ich den besagten Fehler :-(
Sind die Deklaration und Definition an den richtgen Stellen???
Hoffe ihr könnt mir helfen...
MFG xxxbolsbluexxx