简体   繁体   English

错误:“类std :: stack <>”没有名为“ pop_back”的成员

[英]error: 'class std::stack<>' has no member named 'pop_back'

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;
    }
}

I am getting the following compile time error: 我收到以下编译时错误:

/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' 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

Thanks in advance for the help. 先谢谢您的帮助。

Change push_back to push and pop_back to pop . push_back更改为push ,将pop_back更改为pop For more information, use a good reference . 有关更多信息,请使用参考

std::stack<> has a member function named pop , and another named push . std::stack<>具有一个名为pop的成员函数,另一个名为push的成员函数。 The stack can only do operations on the back, it is just push and pop . 堆栈只能在背面进行操作,只是pushpop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM