--------------------Configuration: TicTacToe - Win32 Debug--------------------Code:/* WE NEED A CLASS NAMED PLAYER WITH METHOD TAKESQUARE WE NEED A CLASS NAMED BOARD WITH METHOD CLEAR AND SET SQUARE WE NEED AN ARRAY NAMED BOARDVECTOR [3][3] */ #include <iostream> #include <string> using namespace std; //========================================================= class PlayingArea { public: PlayingArea(); ~PlayingArea(); int ClearBoard(); //this will clear the board and start a new game int SetSquare(int SquareTaken, string Symbol); //this will place an X or and O in the appropriate space private: string BoardVector[3][3]; //this is the tic tac toe board }; class Player { public: Player(); ~Player(); int TakeSquare(); //this will return which square the user wishes to take. void Symbol(); int Wins; int Losses; int Ties; int SquareTaken; private: string PlayerSymbol; }; //========================================================== int PlayingArea::ClearBoard() { int z=1; for (int x=1; x < 4; x++){ int y=1; BoardVector[x][y] = z; z++; y++; BoardVector[x][y] = z; z++; y++; BoardVector[x][y] = z; z++; y++; } return(0); } //=========================================================== int PlayingArea::SetSquare(int SquareTaken, string Symbol) { int z=1; for (int x=1; x < 4; x++){ int y=1; if (z == SquareTaken){ BoardVector[x][y] = Symbol; } z++; y++; if (z == SquareTaken){ BoardVector[x][y] = Symbol; } z++; y++; if (z == SquareTaken){ BoardVector[x][y] = Symbol; } z++; y++; } return(0); } //=========================================================== PlayingArea() { return NULL; } //=========================================================== ~PlayingArea() { return NULL; } //=========================================================== Player() { return NULL; } //=========================================================== ~Player() { return NULL; } //=========================================================== int main() { PlayingArea Board; Player PlayerA; Player PlayerB; return(0); }
Compiling...
Source.cpp
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(118) : error C2588: '::~PlayingArea' : illegal global destructor
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(119) : error C2084: function 'int __cdecl PlayingArea(void)' already has a body
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(132) : error C2588: '::~Player' : illegal global destructor
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(133) : error C2084: function 'int __cdecl Player(void)' already has a body
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(142) : error C2146: syntax error : missing ';' before identifier 'Board'
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(142) : error C2065: 'Board' : undeclared identifier
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(143) : error C2146: syntax error : missing ';' before identifier 'PlayerA'
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(143) : error C2065: 'PlayerA' : undeclared identifier
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(144) : error C2146: syntax error : missing ';' before identifier 'PlayerB'
C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Sams C++\Lesson 10\TicTacToe\Source.cpp(144) : error C2065: 'PlayerB' : undeclared identifier
Error executing cl.exe.
TicTacToe.exe - 10 error(s), 0 warning(s)