|
From: Ioannis V. <no...@ho...> - 2002-03-26 19:28:50
|
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Danny
Austin
Sent: Monday, March 25, 2002 2:56 AM
To: dev...@li...
Subject: [Dev-C++] errors
HEY GUYS,
I'm that newbie guy that keeps having trouble. I got a book "C++ for
the absolute beginner," well this beginner doesn't still get it. So I'm
wondering if you can explain what the book is failing to explain. Below
is a program I typed in, that is giving me fits over "enum" and all its
"returns" I feel like I missing something in my lib.'s but I'm not sure.
I have double checked everything several times to the book and from all
that I can see I have typed it out just as the book has it. I take it
though one complier will do things differently than another and I know
the author is using a different complier. So if anyone can help me I'm
all ears.
enums are user defined discrete integer types.
THANKS DANNY!!
//6.5 - Tic Tac Toe
#include <iostream>
#include <string>
using namespace std;
enum SquareState { blank = ' ' , X = 'X', 0= '0' };
0='0'?
enum SquareState { blank=' ', X='X', O='0'};
class gameBoard
{
private:
const int WIDTH;
const int HEIGHT;
int* GameBoard;
public:
gameBoard() : WIDTH(3), HEIGHT(3)
{
GameBoard = new int[9];
for (int i = 0; i < 9; i++)
*(GameBoard + i) = blank;
}
~gameBoard() {delete[] GameBoard;}
void setX(int h, int w);
void set0(int h, int w);
bool isTaken(int h, int w);
SquareState isLine();
void draw();
};
void gameBoard::setX(int h, int w)
{
*(GameBoard + h*HEIGHT + w) = X;
}
void gameBoard::set0(int h, int w)
{
*(GameBoard + h*HEIGHT + w) = 0;
}
bool gameBoard::isTaken (int h, int w)
{
return *(GameBoard + h*HEIGHT + w) != ' ';
}
SquareState gameBoard::isLine()
{
if(*GameBoard==X && *(GameBoard +1)==X && *(GameBoard +2)==X)
return X;
if(*GameBoard==0 && *(GameBoard +1)==0 && *(GameBoard +2)==0)
return 0;
0 doesn't belong to type SquareState. Result is truncated.
Ioannis
* Ioannis Vranos
* Programming pages: <http://www.noicys.cjb.net/>
http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|