1
class Board
{
public:
enum Player {X = -1, O, E};
bool win(Player P); // A function that returns true if Player P has won the game, and
// false otherwise.
}; // end class board
以上是我的Tic-Tac-Toe遊戲頭文件的一部分。我想測試的勝利功能和困惑於如何從驅動程序文件進行測試:如何在頭文件中使用外部枚舉類型?
#include <iostream>
using namespace std;
#include "Board.h"
// function main begins program execution
int main()
{
Board a;
cout << a.win(X) << endl; // <------------------? ? ?
return 0; // indicate successful termination
} // end function main
我試圖創建主一局::播放器類型,但仍無法得到它的編譯。有什麼建議麼?
太謝謝你了! – Brandon 2009-12-30 11:43:11