employee.h

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

H
59
字号
// Header file for the Employee class, the base class for// maintaining employee records#ifndef CLASS_Employee#define CLASS_Employee#include <string>#include <iostream>class Employee {public:	// Constructor	Employee( const std::string& name, 		const std::string& SSN );	// Copy constructor	Employee( const Employee& e );	// By declaring the destructor virtual, we ensure that	// if we delete a pointer to an Employee object, but	// the object belongs to a derived class, the destructor	// for the derived class will be called as well	virtual ~Employee();		// Get/Set pairs to work with member variables	inline std::string GetName() const { return m_Name; }	inline void SetName( const std::string& name ) { m_Name = name; }		inline std::string GetSSN() const { return m_SSN; }	inline void SetSSN( const std::string& ssn ) { m_SSN = ssn; }		// The = 0 makes this function pure virtual, and	// makes this entire class an abstract base class,	// so you cannot create an Employee object!  You	// must create an instance of a derived class	virtual double GetYearlyPay() const = 0;	// Making this function virutal ensures that the proper	// SendTo function will be called, depending on the	// kind of employee this object actually is	virtual void SendTo( std::ostream& out ) const;	protected:	// These members are available to derived classes,	// but not to outside code	std::string m_Name;	std::string m_SSN;	private:	// This is an entity type, so we don't want the 	// compiler implementing a public assignment operator!	// Defining a private assignment operator prevents this	Employee& operator=( const Employee& e );	} ;// Output operator works with any kind of employeestd::ostream& operator<<( std::ostream& out, 	const Employee& e );#endif // CLASS_Employee

⌨️ 快捷键说明

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