From: Scott Worley Date: Fri, 1 Jan 2016 06:03:37 +0000 (-0800) Subject: Mark const methods const. X-Git-Url: http://git.scottworley.com/slidingtile/commitdiff_plain/cea272cfec1cf181ca673cc9454517b6d91a4f97 Mark const methods const. --- diff --git a/sliding_tile_lib.cc b/sliding_tile_lib.cc index b8ddc15..5b2e798 100644 --- a/sliding_tile_lib.cc +++ b/sliding_tile_lib.cc @@ -22,7 +22,7 @@ signed char adjacent[BOARD_SIZE][5] = { 11, 14, -1, -1, -1, }; -bool Board::is_valid() { +bool Board::is_valid() const { bool seen[BOARD_SIZE]; for (int i = 0; i < BOARD_SIZE; i++) { seen[i] = false; @@ -65,7 +65,7 @@ std::istream& operator>>(std::istream& is, Board& board) { return is; } -signed char Board::hole() { +signed char Board::hole() const { for (int i = 0; i < BOARD_SIZE; i++) { if (board[i] == 0) { return i; diff --git a/sliding_tile_lib.h b/sliding_tile_lib.h index 84d422e..4d6c015 100644 --- a/sliding_tile_lib.h +++ b/sliding_tile_lib.h @@ -8,8 +8,8 @@ const int BOARD_SIZE = BOARD_DIM * BOARD_DIM; struct Board { signed char board[BOARD_SIZE]; - bool is_valid(); - signed char hole(); + bool is_valid() const; + signed char hole() const; }; std::istream& operator>>(std::istream& is, Board& board);