bekomme beim "maken" folgende Fehlermeldung:
Code: Alles auswählen
matthias@debian:~/Desktop/st_a4/code$ make
cc -c -I -O2 Sample.cpp
Sample.cpp: In function ‘std::ostream& operator<<(std::ostream&, const Sample&)’:
Sample.cpp:133: error: passing ‘const Sample’ as ‘this’ argument of ‘void Sample::writeSample(std::ostream&)’ discards qualifiers
make: *** [Sample.o] Fehler 1
matthias@debian:~/Desktop/st_a4/code$
Sample.cpp
Code: Alles auswählen
void Sample::writeSample(ostream& strm)
{
//Muster: 20.01.2011 16:30 5 40.6 39.8 40.1 38.9 40.2
double tmp;
strm << date << " ";
strm << time << " ";
strm << quantity << " ";
for(int i=0;i<quantity;i++)
{
strm << results[i] << " ";
}
strm << endl;
}
ostream& operator<<(ostream& strm, const Sample& s)
{
s.writeSample(strm);
return(strm);
}
Code: Alles auswählen
[ ... ]
void writeSample(ostream& strm=cout);
[ ... ]
};
//global declarations
ostream& operator<<(ostream& strm, const Sample& s);
istream& operator>>(istream& strm, Sample&);
#endif
Danke schon mal im Voraus!
Gruß, Matt