When trying to run, the compiler tells me that I cannot access the private data members. I'm just curious as to what's causing this error. Here's my class declaration:
#include <iostream>
#include <string>
using namespace std;
#ifndef SALARY_H
#define SALARY_H
class Salary
{
public: const int getDepNum();
const int getWorkerID();
const double getYearlySalary();
const string getDepartment();
void setDepNum(int x);
void setWorkerID(int x);
void setYearlySalary(double x);
void setDepartment(string x, Salary salary);
const double newSalary();
const double monthlySalary();
const double weeklySalary();
private: int depNum, workerID;
double yearlySalary;
string department;
friend ostream& operator <<(ostream &out, Salary &x);
friend istream& operator >>(ifstream &in, Salary &x);
};
#endif
and the definition:
istream& operator >> (istream &in, Salary &x)
{
in >> x.depNum >> x.workerID >> x.yearlySalary;
return in;
}