I am developing a program that creates random mazes. One part of the program involves keeping track of the correct path. Each point on the path is a (row, column) coordinate. I am trying to store each coordinate as a 2 element integer array and push it back onto a vector of all the coordinates in the correct path, but I'm not having much success. Here's the code, stripped down to get right to the error, which is in line 58.
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
using namespace std;
class Maze
{
private:
char wallChar;
char pathChar;
char spaceChar;
char startChar;
char finishChar;
char curPosChar;
int numRows;
int numCols;
int curPosition[2];
int startPosition[2];
int finishPosition[2];
char** mazeGrid;
vector <int[2]> correctPath;
int facingDirection;
public:
Maze (int numrows, int numcols, char wallchar, char pathchar, char spacechar, char startchar, char finishchar, char curposchar);
~Maze ();
void Maze::DisplayMaze (bool showSolution, bool showPosition, bool showDirection);
void DisplayMaze (bool showSolution);
void PositionAtStart ();
void PositionAtFinish ();
void setPosition ();
bool MazeSolved ();
bool Move (int newX, int newY);
bool Move (int direction);
bool Move ();
bool Turn (bool turnRight);
void GetMazePath ();
};
int main ()
{
srand (time(NULL));
Maze* maze = new Maze (21, 21, '#', '@', ' ', 'S', 'F', '?');
return 0;
}
Maze::Maze (int numrows, int numcols, char wallchar, char pathchar, char spacechar, char startchar, char finishchar, char curposchar)
{
int point[2];
point[0] = 1;
point[1] = 3;
correctPath.push_back (point);
}
Maze::~Maze ()
{
}
So the questions are:
1) What am I doing wrong?
2) Is it possible to store the coordinates this way (a vector of 2-element arrays) and if so, what do I need to change?
3) If not, do I need to create a Coordinate class that has the 2 element array as the lone data member and have a vector of Coordinate? Or should I use http://www.cplusplus.com/reference/std/utility/pair.html ?
Thank you.