hourly.h
来自「斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》」· C头文件 代码 · 共 51 行
H
51 行
// Header file for the Hourly class, derived from the// Employee base class and used to maintain records for// employees paid at an hourly rate#ifndef CLASS_Hourly#define CLASS_Hourly#include "employee.h" // Always include base class header#include "emp_exceptions.h"class Hourly : public Employee {public: Hourly(); // for reading from file Hourly( const std::string& name, const std::string& ssn, double payrate, int hours ); Hourly( const Hourly& h ); ~Hourly(); // Get/Set pairs for working with member variables inline double GetPayRate() const { return m_PayRate; } inline void SetPayRate( double r ) { m_PayRate = r; } inline int GetHoursPerWeek() const { return m_HoursPerWeek; } inline void SetHoursPerWeek( int h ) { m_HoursPerWeek = h; // Complain if attempt to set hours too low if ( h < 10 ) throw LazyException( m_Name, m_HoursPerWeek ); } // Computes and returns yearly pay, using hourly pay // rate and hours worked per week double GetYearlyPay() const; // Called by << operator to output member variables // specific to salaried employees void SendTo( std::ostream& out ) const; // Called by >> operator to read member variables // specific to salaried employees void GetFrom( std::istream& in, bool prompt = false ); private: double m_PayRate; // hourly pay rate int m_HoursPerWeek; // number of hours worked per week // This is declared private to prevent assignment Hourly& operator=( const Hourly& h ); } ;#endif // CLASS_Hourly
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?