views:

57

answers:

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

The above is part of my header file for a Tic-Tac-Toe game. I am trying test the win function and confused on how to test it from a driver file:

#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

I have tried to create a Board::Player type in main but still cannot get it to compile. Any suggestions?

+3  A: 

In C++, you always have to think about scope, so:

cout << a.win(X) << endl;

should be:

cout << a.win(Board::X) << endl;
anon
Thank you so much!
Brandon