⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 employee.cpp

📁 数据结构课程第一次实验 要求:1.基类和派生类的定义和实现(.h .cpp) 2.+ 运算符重载 3.<< 运算符重载 4.构造与重载函数应用
💻 CPP
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -