?? hourly.cpp
字號:
// Implementation file for the Hourly class#include "hourly.h"using namespace std;Hourly::Hourly( const string& name, const string& ssn, double payrate, int hours ) : Employee( name, ssn ) { // First the base class constructor is called, to store // the name and ssn. Here, we store the hourly pay // rate and the hours worked per week cout << "Constructing an hourly employee!" << endl; m_PayRate = payrate; m_HoursPerWeek = hours;}Hourly::Hourly( const Hourly& h ): Employee( h ) { // Copy data members that haven't already been copied // using the base class copy constructor m_PayRate = h.m_PayRate; m_HoursPerWeek = h.m_HoursPerWeek;}Hourly::~Hourly() { // Nothing to destroy here, because the data members // will be de-allocated automatically cout << "Destroying an hourly employee!" << endl;}double Hourly::GetYearlyPay() const { // Compute yearly pay from hourly rate, hours per week // and weeks per year return m_PayRate * m_HoursPerWeek * 52;}void Hourly::SendTo( ostream& out ) const { // First call base class function Employee::SendTo( out ); // Now output class-specific members out << "Hourly Pay: $" << m_PayRate << " per hour" << endl; out << "Hours Per Week: " << m_HoursPerWeek << endl;}Hourly& Hourly::operator=( const Hourly& h ) { // 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 + -