salaried.cpp

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

CPP
44
字号
// Implementation file for the Salaried class#include "salaried.h"using namespace std;Salaried::Salaried( const string& name,	const string& ssn, 	double salary ) : Employee( name, ssn ) {	// First the base class constructor is called, to store	// the name and ssn.  Here, we store the salary	cout << "Constructing a salaried employee!" << endl;	m_Salary = salary;}Salaried::Salaried( const Salaried& s ) : Employee( s ) {	// Copy data members that haven't already been copied	// using the base class copy constructor	m_Salary = s.m_Salary;}Salaried::~Salaried() {	// Nothing to destroy here, because the data members	// will be de-allocated automatically	cout << "Destroying a salaried employee!" << endl;}double Salaried::GetYearlyPay() const {	// Multiply monthly salary by months in a year	return m_Salary * 12;}void Salaried::SendTo( ostream& out ) const {	// First call base class function	Employee::SendTo( out );	// Now output class-specific members	out << "Salary: $" << m_Salary << " per month" << endl;}Salaried& Salaried::operator=( const Salaried& s ) {	// We don't need this operator to do anything since	// we never want it to be used	return *this;}

⌨️ 快捷键说明

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