我正在建造三個類,迷宮,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