employee.cpp

来自「数据结构课程第一次实验 要求:1.基类和派生类的定义和实现(.h .cpp) 」· C++ 代码 · 共 26 行

CPP
26
字号
#include <iostream>
#include <string>
#include "Employee.h"

using namespace std;

Employee::Employee(string a,int b) 
{
	name=a;
	salary=b;
}

Employee operator+(Employee& ex_a, Employee& ex_b)          //重载运算符+
{
	ex_a.name   = ex_a.name + " and " + ex_b.name;
	ex_a.salary = ex_a.salary + ex_b.salary;
	return ex_a;
}

ostream& operator<<(ostream& output, Employee& ex)          //重载流插入运算符<<
{
	output << "The employee's name is "   << ex.name   << endl;
	output << "The employee's salary is " << ex.salary << endl;
	return output;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?