I am working on a project for class that is a sort of payroll. Part of the prompt says
"You may define a friend function that overloads << for displaying the Employee object information(i.e. the overloading << function will call the virtual print function.)"
I know what a friend function is, but I don't recall learning about the overloading << part. I tried searching for some easy copy paste implementation... but my compiler flares up no matter what I try.
How do I go about actually implementing this? Here's the code I have so far:
#include <iostream>
#include <string>
using namespace std;
//Base class
class Employee
{
public:
Employee(string a, string b, string c, string d);
~Employee();
int virtual earnings();
void virtual print();
protected:
string first, last, brithday, department;
};
Employee::Employee(string f, string l, string b, string d)
{
first = f;
last = l;
brithday = b;
department = d; //department code
cout << "Employee created." << endl;
}
Employee::~Employee(void)
{
cout << "Employee deleted." << endl;
}
int Employee::earnings()
{
int earnings = 100; //To be added
return earnings;
}
void Employee::print()
{
//IDK
}