Error with a For Loop in a Class Function

I have created a board in the form of a class.
This is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Board
{
private:
	char board[9];
public:
	void SetBoard();

}

void Board::SetBoard()
{
	for( int i = 0;i < 9; i++);
	{
		board[i] = ' ';
	}
}


The Line with the comment is giving the error:
'i' : undeclared identifier
Now this is the first time I have encountered this error as i should be defined in the for loop.
Any help??
Last edited on
You mistakenly added a semicolon at the end of for.
So the following block is not part of the for loop and thus i isn't declared.
Thanks! Such a foolish mistake...
The problems are right here:

1
2
3
4
5
6
7
8
class Board
{
private:
	char board[9];
public:
	void SetBoard();

} // Missing something? 


1: You are missing semicolon at the end of class definition. Remember, in C++, it´s essential.

for( int i = 0;i < 9; i++); // Why extra semicolon?

2: One extra semicolon at the end of that line. Please remove it & see if it works.
Last edited on
It seems some error in Copying, since I did put an semicolon at the end of the class.
As for the Extra semi-colon, Athar already pointed it out!
None-the-less thanks!
Man, I was too slow replying...
Topic archived. No new replies allowed.