employee.cpp

来自「斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》」· C++ 代码 · 共 46 行

CPP
46
字号
// Implementation file for the Employee class#include "employee.h"using namespace std;Employee::Employee( const string& name, const string& ssn ) {	// Store arguments in member variables	cout << "Constructing an employee!" << endl;	m_Name = name;	m_SSN = ssn;}Employee::Employee( const Employee& e ) {	// Copy data members from e	m_Name = e.m_Name;	m_SSN = e.m_SSN;}Employee::~Employee() {	// Nothing to destroy here, because the data members	// will be de-allocated automatically	cout << "Destroying an employee!" << endl;}void Employee::SendTo( ostream& out ) const {	// Output data members	out << "Name: " << m_Name << endl;	out << "SSN: " << m_SSN << endl;	out << "Yearly Pay: $" << GetYearlyPay() << endl;}Employee& Employee::operator=( const Employee& e ) {	// We don't need this operator to do anything since	// we never want it to be used	return *this;}ostream& operator<<( ostream& out, const Employee& e ) {	// Regardless of the kind of employee is passed, the	// appropriate SendTo function will be called, because	// it's declared virutal in the Employee class	e.SendTo( out );	return out;}

⌨️ 快捷键说明

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