📄 salaried.cpp
字号:
// Implementation file for the Salaried class#include "salaried.h"#include "emp_exceptions.h"using namespace std;Salaried::Salaried( const string& name, const string& ssn, double salary ) : Employee( name, ssn ) { cout << "Constructing a salaried employee!" << endl; m_Salary = salary;}Salaried::Salaried( const Salaried& s ) : Employee( s ) { 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 double pay = m_Salary * 12; // If pay turns out to be too high, complain if ( pay > 100000.0 ) throw OverpaidException( m_Name, pay ); return pay;}void Salaried::SendTo( ostream& out ) const { Employee::SendTo( out ); out << "Salary: $" << m_Salary << " per month" << endl;}void Salaried::GetFrom( istream& in, bool prompt ) { Employee::GetFrom( in, prompt ); if ( prompt == true ) cout << "Monthly Salary: "; in >> m_Salary;}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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -