Last active
September 30, 2015 14:43
-
-
Save cocodrips/1db5b3d70198f84ae18c to your computer and use it in GitHub Desktop.
2次元配列問題 クラス化
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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