I'm quite new to C++ and coding in general and I have been stuck on this bug for forever it seems.
My eventual goal is to create a tic-tac-toe algorithm but at the moment I am having an issue with using struct variables outside of the struct.
I have tried using classes and structs, using static etc., I know I am missing something I just don't know what it is.
Heres the code, it's not exactly beautiful but I'm pretty sure it should work.
#include <iostream>
#include <string>
int userResponse;
//Class to monitor board positions
struct boardPos
{
bool Pos1 = 0;
bool Pos2 = 0;
bool Pos3 = 0;
bool Pos4 = 0;
bool Pos5 = 0;
bool Pos6 = 0;
bool Pos7 = 0;
bool Pos8 = 0;
bool Pos9 = 0;
};
//Changing bool values
void boolChange()
{
if (userResponse == 1)
{
boardPos::Pos1 = 1;
}
if (userResponse == 2)
{
boardPos::Pos2 = 1;
}
if (userResponse == 3)
{
boardPos::Pos3 = 1;
}
if (userResponse == 4)
{
boardPos::Pos4 = 1;
}
}
//std::string A, B, C, D, E, F, G, H, I
int main()
{
//Variable to Print Position Board
std::string posBoard = "\n 1 | 2 | 3\n-----------\n 4 | 5 | 6\n-----------\n 7 | 8 | 9\n";
std::cout << posBoard;
std::cout << "Enter Position Number\n";
std::cin >> userResponse;
}