#include <stack>
#include <functional>
int main()
{
std::stack<std::function<int()>> s;
s.push(main);
return s.top()();
}
我得到以下诊断信息:
result: runtime error time: 0.04s memory: 39704 kB signal: 11 (SIGSEGV)
这是怎么回事?
最佳答案
首先,您不能自己调用main
。其次,它似乎在做“你所期望的”并进行调用,所以你导致了无限递归,它耗尽了你所有的堆栈空间,然后溢出。
关于c++ - 堆栈运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16661134/