I am building three classes, Maze, MazeRow, and MazePoints, to hold a maze structures and I am having trouble with setting up my vector for the MazeRows.The below code is from my Maze class code. I have included my header file for MazeRow. I am getting 3 errors each where i am calling a vector method. Also myMazeRows is a private member variable of Maze Class
//Maze Header File
#include "MazeRow.h"
#include <vector>
using namespace std;
namespace MazeSolver
{
class Maze
{
public:
Maze(int rows, int columns);
MazeRow * getRow(int row);
private:
vector<MazeRow> myMazeRows();
//Maze Implementation File
#include "stdafx.h"
#include "Maze.h"
#include <vector>
using namespace std;
using namespace MazeSolver;
Maze::Maze(int rows, int columns)
{
//Recieving the Compile Error (C2228)
myMazeRows.resize(rows);
//Initializing Each Row
for(int i=0; i< rows;i++) //Recieving the Compile Error ( C2228 )
myMazeRows.push_back(MazeRow(i,columns));
}
MazeRow* Maze::getRow(int row)
{
//Recieving the Compile Error (C2228)
return &myMazeRows.at(row);
}
//Maze Row Header File
class MazeRow
{
public:
MazeRow(int rowNum, vector<MazePoint>);
MazeRow(int rowNum, int mazPoints);
At least one error the Maze::GetRow() should be:
Another possibly is that your loop in Maze constructor is to
i<rows-1— most likely should bei<rows. This will not cause compilation error, but runtime problems.