编程中堆栈溢出和缓冲区溢出有什么不同?
任何人都可以告诉我如何捕获内存异常?
对于前
try
{
while(true)
{
int i = new int;
}
}
catch( ? <--- what should be put here?)
{
//exception handling
}
Run Code Online (Sandbox Code Playgroud)
还有这个,
queue<int> q;
try
{
while(true)
{
q.push(10);
}
}
catch( ? <---- what should be put here?)
{
//error handling
}
Run Code Online (Sandbox Code Playgroud) 什么可以是C++中的一个简单示例,在从方法调用调用和返回的情况下导致堆栈下溢.我熟悉调用约定,即thiscall,stdcall和cdecl以及它们清理堆栈的方式.具体来说,编译器自动为我生成的代码是否会不会出现堆栈下溢?
什么情况可以让我陷入堆栈下溢的麻烦?