Good evening ladies and gentlement.
I have been working a project in C++. I have TTTMain.cpp file that has all the function calls, TTTFuntions.cpp that has all the functions, I have TTT.h file that has all the prototypes and variables and additionally I have Winner.h that has enum class Winner declaration in it. Here is my block of codes:
Winner.h file:
1 2 3 4 5 6 7 8 9 10
|
#ifndef winner
#define winner
enum class Winner
{
Empty,
Computer,
Player
};
#endif
|
TTT.h file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
[output][/output]
#ifndef TTT
#define TTT
#include <iostream>
#include <cmath>
#include "Winner.h"
using namespace std;
class TTT
{
public:
Winner gameSquares[] = { Empty, Empty,Empty, Empty, Empty, Empty, Empty, Empty, Empty };
int movesMade = 0;
void HowTo();
void PlayerTurn();
bool FirstGo();
int GetPossibleMoves(int possible_index[9], Winner who, const Winner *const board = gameSquares);
int GetWinIndex(const Winner who);
void ComputerTurn();
void PrintBoard();
};
#endif
|
My question is when I compile this gives me error on
Winner gameSquares[] = { Empty, Empty,Empty, Empty, Empty, Empty, Empty, Empty, Empty };
with saying "invalid use of non-static data data member"
and It says "Empty was not declared in this scope."
I know calling enum is very very trick. How possibly could I solve this problem?I have been trying to figure it out for a while but I gave up on! Thanks for your time and attention