Header:
#ifndef patientenliste_hpp
#define patientenliste_hpp
#include <vector>
#include <iostream>
#include "patient.hpp"
using namespace std;
class Patientenliste
{
private:
vector<Patient> liste;
public:
Patientenliste& operator+= (const Patient&);
friend ostream& operator<< (ostream&, const Patientenliste&);
};
ostream& operator<< (ostream&, const Patientenliste&);
#endif
Sourcecode:
#include "patientenliste.hpp"
Patientenliste::Patientenliste& operator+= (const Patient& p)
{
liste.push_back(p);
return *this;
}
ostream& operator<< (ostream& os, const Patientenliste& p)
{
for(auto& i : p.liste)
os << i;
return os;
}
Why do I have to put "Patientenliste::" before "liste" in the operator definition += in the Sourcecode? Eclipse can't resolve it, but it should do, isn't it? Worked fine with my previous project...
This
Patientenliste::Patientenliste& operator+= (const Patient& p)
should be
Patientenliste& Patientenliste::operator+= (const Patient& p)
You are using Patientenliste::
as operator+= is in scope of that class i.e member of that class.