Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Last active September 30, 2015 14:43
Show Gist options
  • Save cocodrips/1db5b3d70198f84ae18c to your computer and use it in GitHub Desktop.
Save cocodrips/1db5b3d70198f84ae18c to your computer and use it in GitHub Desktop.
2次元配列問題 クラス化
struct Pos {
int x, y;
Pos (int _x, int _y) {
x = _x; y = _y;
}
bool operator==(const Pos &other) const {
return x == other.x && y == other.y;
}
};
struct Board {
private:
char _board[Y * X];
public:
char operator[](Pos pos) const {
return _board[pos.y * X + pos.x];
}
char &operator[](Pos pos) {
return _board[pos.y * X + pos.x];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment