Overloading stream extraction operator

Hi everyone. I am new here. First time. First topic. First post. First everything.
Anyway, my question is about the stream extraction operator.
I have a header file, employee.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include<iostream>
using namespace std;
class employee{
		string emp_name;
		int sales;
public:
		void display_highest();
		friend istream& operator>>(istream& isObject, employee& x);
		employee();
	};


#endif 


seems pretty fine. The error is in my employee.cpp file (implementation file). Says "No operator >> matches these operands"

here is my code in the employee.cpp file (snippet)

1
2
3
istream& operator>>(istream& isObject, employee& x){
	isObject>>x.emp_name;
}


What am I doing wrong here?
Is there an #include <string> lurking about somewhere?
u must return istream object.
1
2
3
4
istream& operator>>(istream& isObject, employee& x){
	isObject>>x.emp_name;
          return isObject;
}
cire (5966) Thanks! I can't believe I missed that. I thought I needed to overload the extraction operator. That worked.
Topic archived. No new replies allowed.