我正在建造三个类,迷宫,MazeRow和MazePoints,以保持迷宫结构,并且我无法为MazeRows设置我的矢量。下面的代码来自我的Maze类代码。我已经包含MazeRow的头文件。每次我调用矢量方法时,都会收到3个错误。也myMazeRows是迷宫的私有成员变量为什么我得到这个错误,'method'的左边必须有class/struct/union?
类//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);
哪条线显示错误?什么是* actual *错误信息(复制和粘贴)?还请显示'myMazeRows'的实际定义。 – 2012-03-22 02:38:02
你有没有合适的#include? – Benoir 2012-03-22 02:50:04
如果您向我们展示'myMazeRows'的声明,可能会有所帮助。而且,正如@Benoir暗示的那样,您可以向我们展示'#include'语句。 – aldo 2012-03-22 03:08:12