emp_exceptions.h
来自「斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》」· C头文件 代码 · 共 51 行
H
51 行
// Header file for employee-related exception classes#ifndef EMP_EXCEPTIONS#define EMP_EXCEPTIONS#include <string>// Base class for any employee-related error conditionclass EmpException {public: EmpException( std::string name ) { m_Name = name; } EmpException( const EmpException& e ) { m_Name = e.m_Name; } virtual ~EmpException() {} // This makes class abstract virtual void Complain() const = 0; protected: std::string m_Name; // name of offending employee} ;// Derived class used to complain about overpaid employeesclass OverpaidException : public EmpException {public: OverpaidException( std::string name, double salary ); OverpaidException( const OverpaidException& e ); ~OverpaidException() {} // Outputs specific complaint void Complain() const; private: double m_Salary; // excessive yearly salary} ;// Derived class used to complain about hourly employees// who don't work enough hours per weekclass LazyException : public EmpException {public: LazyException( std::string name, int hours ); LazyException( const LazyException& e ); ~LazyException() {} // Outputs specific complaint void Complain() const; private: int m_Hours; // Hours offending employee works per week} ;#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?