spreadsheetcell.h
来自「C++高级编程这本书所附的源代码」· C头文件 代码 · 共 57 行
H
57 行
#ifndef _SPREADSHEET_CELL_H_#define _SPREADSHEET_CELL_H_#include <string>using std::string;class SpreadsheetCell{ public: SpreadsheetCell(); SpreadsheetCell(double initialValue); explicit SpreadsheetCell(const string& initialValue); SpreadsheetCell(const SpreadsheetCell& src); SpreadsheetCell& operator=(const SpreadsheetCell& rhs); void set(double inValue); void set(const string& inString); double getValue() const {mNumAccesses++; return (mValue); } string getString() const {mNumAccesses++; return (mString); } static string doubleToString(double inValue); static double stringToDouble(const string& inString); friend const SpreadsheetCell operator+(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); friend const SpreadsheetCell operator-(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); friend const SpreadsheetCell operator*(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); friend const SpreadsheetCell operator/(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); SpreadsheetCell& operator+=(const SpreadsheetCell& rhs); SpreadsheetCell& operator-=(const SpreadsheetCell& rhs); SpreadsheetCell& operator*=(const SpreadsheetCell& rhs); SpreadsheetCell& operator/=(const SpreadsheetCell& rhs); friend bool operator==(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); friend bool operator<(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); friend bool operator>(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); friend bool operator!=(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); friend bool operator<=(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); friend bool operator>=(const SpreadsheetCell& lhs, const SpreadsheetCell& rhs); protected: double mValue; string mString; mutable int mNumAccesses;};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?