So, I tried my hand in C ++ after finishing the introductory book, and I'm stuck. I created a vector of objects, each of which has an SFML circle object as a member, and I want main () to go and draw these circles. The vector is called theBoard, but when I try to access it, I get the following error messages:
error: request for member 'theBoard' in 'GameBoard', which is of non-class type 'Board*'
error: 'theBoard' was not declared in this scope
I am new to this (came from two years old Python), so I'm sure I was mistaken somewhere. Here is the appropriate code to create the board:
class Board
{
public:
Board();
~Board();
vector<Space*> CreateBoard();
vector<Space*> theBoard;
vector<Space*> Cluster1;
vector<Space*> Cluster2;
vector<Space*> Cluster3;
private:
vector<int> RowNums;
};
Board::Board()
{
RowNums.push_back(1);
RowNums.push_back(17);
RowNums.push_back(2);
RowNums.push_back(17);
RowNums.push_back(1);
RowNums.push_back(1);
RowNums.push_back(5);
RowNums.push_back(2);
RowNums.push_back(7);
RowNums.push_back(2);
RowNums.push_back(11);
RowNums.push_back(3);
RowNums.push_back(17);
RowNums.push_back(4);
RowNums.push_back(17);
theBoard = CreateBoard();
}
CreateBoard() - , Space. , , , Space main(). , theBoard , Board.
main(), :
int main()
{
sf::RenderWindow App(sf::VideoMode(1200, 900, 32), "Malefiz");
Board* GameBoard = new Board();
cout << "Board made.";
while(App.IsOpened())
{
sf::Event Event;
while(App.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
{
App.Close();
}
}
App.Clear(sf::Color(200, 200, 125));
for(int i = 0; i < GameBoard.theBoard.size(); ++i)
{
App.Draw(GameBoard.*theBoard[i].m_Circle);
}
App.Display();
}
return EXIT_SUCCESS;
}