Hi,
Welcome to Cplusplus :+)
Just mentioned this, one can make a URL link by quoting the web address.
Ok, with your code.
I like to use *.hpp as opposed to *.h for header files, it means there is cpp code in the file.
Looking at Board.h:
Only include header files you need.
Don't have
using namespace std;
, put std:: before each std thing, believe me it's the best way. Google to what is bad about
using namespace std;
max_col
and
max_row
should be
unsigned
, or
std::size_t
, or one of the unsigned types found in
<cstdint>
header.
Line 24: Put 1 statement per line
Looking at Board.cpp:
Is Obstacle needed in this file?
Board::initialize
is a little misleading, it only initialises 1 square
Board::display
is a little misleading, it only displays 1 square
Board::get_col
and
Board::get_row
return their respective max size, so the function name is misleading.
You could have a function called
ValidSquare
say, so you don't have this repeated:
get_square(col, row) == blank && col >= 0 && col < max_col && row >= 0 && row < max_row
Looking at Obstacle.h:
Remove extraneous includes.
You have the board sizes again, an object should be responsible for it's own info, and not be concerned with other objects info. The same goes for functions.
Looking at Obstacle.cpp:
One of the ideas with ctors is to set all the class members and invariants, this is a bit confused at the moment, because you all this other stuff from other classes.
Hopefully this is enough to get you started :+)