电子表格应用程序详解
1. 单元格矩阵(Cell Matrix)
电子表格的单元格以矩阵形式组织,矩阵大小由常量ROWS和COLS决定。m_buffer是一个二维数组,用于存储单元格。
const int ROWS = 10; const int COLS = 5; class CellMatrix { public: CellMatrix(); CellMatrix(const CellMatrix& cellMatrix); CellMatrix operator=(const CellMatrix& cellMatrix); void SetTargetSetMatrix(TSetMatrix* pTargetSetMatrix); Cell* Get(int iRow, int iCol) const; Cell* Get(Reference home) const; void Serialize(CArchive& archive); private: Cell m_buffer[ROWS][COLS]; };- 构造函数:默认构造函数为每个单元格设置指向该单元格矩阵的指针。复制构造函数和赋值运算符逐个复制单元格,并为每个单元格设置单元格矩阵指针。
CellMat