grid.h

来自「C++高级编程这本书所附的源代码」· C头文件 代码 · 共 32 行

H
32
字号
template <typename T, int WIDTH, int HEIGHT>class Grid{ public:  void setElementAt(int x, int y, const T& inElem);  T& getElementAt(int x, int y);  const T& getElementAt(int x, int y) const;  int getHeight() const { return HEIGHT; }  int getWidth() const { return WIDTH; } protected:  T mCells[WIDTH][HEIGHT];};template <typename T, int WIDTH, int HEIGHT>void Grid<T, WIDTH, HEIGHT>::setElementAt(int x, int y, const T& inElem){  mCells[x][y] = inElem;}template <typename T, int WIDTH, int HEIGHT>T& Grid<T, WIDTH, HEIGHT>::getElementAt(int x, int y){  return (mCells[x][y]);}template <typename T, int WIDTH, int HEIGHT>const T& Grid<T, WIDTH, HEIGHT>::getElementAt(int x, int y) const{  return (mCells[x][y]);}

⌨️ 快捷键说明

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