I have a class employee
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
class employee
{
public:
double operator + (employee);
istream& operator>> (istream&);
employee(int);
double getSalary();
private:
double salary;
};
int main()
{
employee A(400);
employee B(800);
employee C(220);
cin>>C;
}
employee::employee(int salary)
{
this->salary = salary;
}
double employee::operator + (employee e)
{
double total;
total = e.salary + this->salary;
return total;
}
double employee::getSalary()
{
return this->salary;
}
istream& employee::operator>> (istream& in)
{
in>>this->salary;
return in;
}
I am trying to overload the input operator >> to read in the employee object but i am getting the following error
no match for operator >> in std::cin
What am i doing wrong ???
edit: I know how to do it through a friend function , i am now trying to learn how to do it through a member function