【发布时间】:2014-03-09 06:29:30
【问题描述】:
我正在做一个类似于工资单的课程项目。部分提示说
"您可以定义一个重载
我知道友元函数是什么,但我不记得学习过重载
我该如何实际实施呢?这是我到目前为止的代码:
#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
}
【问题讨论】:
标签: c++ operator-overloading friend