maverik
11/24/2008 11:48:00 AM
On Nov 24, 2:25 pm, "samum...@gmail.com" <samum...@gmail.com> wrote:
> Hi all. I'm writing a board game for a University project, but i'm in
> trouble on the definition of the Board class
>
> i have class Square (which defines every square of the board by some
> properties) and now i need a container class Board
>
> class Board{
> private:
> int length;
> vector<Square*> B;
> public:
> Board(): B(length){};
> //~Board();
> void setSize(int);
> int Begin();
> int End();
> int moveFW(ints);
>
> };
>
> this is my board.h: setSize let you set the length of the board
> (number of squares) and inside the Board() constructor, i define a
> vector B of square*
Emm. If you mean
> Board(): B(length){};
then it is not inside constructor, AFAIK it called "initialization
list".
> now i need to define the Begin method (returning the first element of
> the board), the End method (the last element)
Why return value of Begin(), End() is int. As I understand you it
should be Square* if you want to return first / last value.
In case of iterators you can try:
typedef std::vector<Square*>::iterator iterator;
typedef std::vector<Square*>::const_iterator const_iterator;
iterator Begin();
const_iterator Begin() const;
iterator End();
const_iterator End() const;
Correct me if I am wrong, cause I'm not sure about that trick.