void MazeSolver::solveMaze()
{
stack<Cell> myStack;
Cell current = myVector.getAt(0, 0);
myStack.push_back(current);
int x, y;
while (myStack.size() != 0)
{
current = myStack.pop_back();
x = current.x_coord;
y = current.y_coord;
}
}
我收到以下编译时错误:
/Users/snihalani/dev/c++rec/c++hw at 7:11PM
➜ main.cpp: In member function 'void hw1::MazeSolver::solveMaze()':
main.cpp:55:17: error: 'class std::stack<hw1::Cell>' has no member named 'push_back'
main.cpp:59:31: error: 'class std::stack<hw1::Cell>' has no member named 'pop_back'
[1] + 18262 exit 1 g+ --std=c++11 main.cpp
提前感谢您的帮助。
答案 0 :(得分:5)
将push_back
更改为push
,将pop_back
更改为pop
。有关详细信息,请使用a good reference。
答案 1 :(得分:4)
std::stack<>
有一个名为pop
的成员函数,另一个名为push
。堆栈只能在后面执行操作,只有push
和pop
。