I keep getting errors while compiling:
non standard syntax – use '&' to create a pointer to member
subscript requires array or pointer type
At this point is where I get the errors:
spot = lucasJumps.getBoard[i];
Do I need to add in *
s and &
s? If so, where do I do that?
#pragma warning(disable:4996)
#include <iostream>
#include <iomanip>
#include "LucasJumps.h"
using namespace std;
// DEFINES
#define NUM_SPOTS 7
int main() {
LucasJumps lucasJumps;
int playerMove = 0;
char theBoard[NUM_SPOTS];
char spot = ' ';
while (lucasJumps.isBoardSolved() == false) {
for (int i = 0; i < NUM_SPOTS; i++) {
spot = &lucasJumps.getBoard[i];
printBoard(spot);
}
cout << "Which tile would you like to move to the empty spot? ";
cin >> playerMove;
while (lucasJumps.slideTile(playerMove) == false) {
cout << "Illegal move. Please try again." << endl;
cout << "Which tile would you like to move to the empty spot? ";
cin >> playerMove;
}
for (int i = 0; i < NUM_SPOTS; i++) {
spot = lucasJumps.getBoard[i];
printBoard(spot);
}
}
cout << "You figured it out! Good job.";
}
void printBoard(char spot) {
HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
for (int i = 0; i < NUM_SPOTS; i++) {
if (spot == 'B') {
SetConsoleTextAttribute(hConsole, COLOR_BLUE);
}
else if (spot == 'R') {
SetConsoleTextAttribute(hConsole, COLOR_RED);
}
else {
SetConsoleTextAttribute(hConsole, COLOR_DEFAULT);
}
cout << " " << spot << " ";
SetConsoleTextAttribute(hConsole, COLOR_DEFAULT);
cout << " ";
}
}
Please login or Register to submit your answer