<< no operator matches these operands

Hey, after google searching I'm still stuck on this problem. I have the same implementation of this code working for a different program so I'm not sure why I'm getting this error. I've crosschecked both programs to no avail and google yielded me no/poor results.

Can someone please tell me how to fix this or where I'm going wrong? Cheers.

The error occurs on the first "<<" in the toString function.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//--PaySlip.cpp—-
#include <iostream>
#include <sstream>
#include <string>
#include "PaySlip.h"
#include "jdate.h"
PaySlip::PaySlip(jdate pd, double hw, double p, double t)  
{
		payDate = pd;
		hoursWorked = hw;
		pay = p;
		tax = t;
}

string PaySlip::toString()
{
		ostringstream ostr;
		ostr << payDate << " " << hoursWorked << "h $" 
		<< pay << " $" << tax << endl;
		return ostr.str();
}



My header file just in case:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef PAYSLIP_H
#define PAYSLIP_H
#include <string>
#include "jdate.h"
using namespace std;
class PaySlip
{
private:
	jdate payDate;
	double hoursWorked;
	double pay;
	double tax;
public:
	PaySlip();  
	PaySlip(jdate pd, double hw, double p, double t);
	string toString();
};

#endif 
Have you overloaded operator<< to work with jdate?
Peter87 is right. Have you overloaded the operator?
Thanks guys, no I didn't I had a crack at that but it was too complicated for me to get my head around what to put in the overloaded function (signature?). I then realized I could just grab the data members of payDate individually like so

1
2
3
4
5
6
7
string PaySlip::toString()
{
		ostringstream ostr;
		ostr << payDate.getDay() << "/" << payDate.getMonth() << "/" << payDate.getYear() << " " << hoursWorked << "h $" 
		<< pay << " $" << tax << endl;
		return ostr.str();
}


Thanks, problem solved.
Yeah, good luck!
Topic archived. No new replies allowed.