class FourRow
{
public:
FourRow():GameLoop(true){}
void CleanArray()
{
for(int y = 0; y<10; y++)
for(int x = 0; x<10; x++)
Array[x][y] = 0;
}
void DrawBoard();
bool GetPlayerInput();
bool CheckIfWon();
protected:
bool GameLoop;
char Array[10][10];
};
//AI.h
class AI : public FourRow
{
public:
AI(){}
void DrawOnBoard();
void Think();
void Speak(int Line);
private:
int AIArray[10][10];
int AIx;
int AIy;
};
help!!!
I don''t know exactly what you mean by that but i guess you have something like this:
If you access Computer.Array it is completely normal that it is empty, even though you filled the data up in Player. Player and Computer are 2 different instances of the FourRow class, thus they are not sharing data. This can be done by making Array static:
Now you can access Array also from the AI class as I showed.
Hope this helped,
Sand Hawk
----------------
-Earth is 98% full. Please delete anybody you can.
My Site
FourRow Player;AI Computer;
If you access Computer.Array it is completely normal that it is empty, even though you filled the data up in Player. Player and Computer are 2 different instances of the FourRow class, thus they are not sharing data. This can be done by making Array static:
// Previous stuffprotected: static char Array[10][10];// Access the array from within any instance of the class:FourRow::Array[X*Y] = ''X'';
Now you can access Array also from the AI class as I showed.
Hope this helped,
Sand Hawk
----------------
-Earth is 98% full. Please delete anybody you can.
My Site
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement