小编acw*_*421的帖子

bad_alloc标识符无法识别?

我收到编译器错误:

错误C2061:语法错误:标识符'bad_alloc'

我以前在其他项目中使用过以下代码块,在try块中有不同的内存分配,没有问题.我希望有人可以向我解释为什么bad_alloc不被VS10识别,尽管它没有在其他程序中引起同样的问题?可能性是我错过了一些轻微的语法问题,但我花了好几个小时试图解决它,此时我觉得我可能对错误视而不见.谢谢您的帮助!

try
{
    node* tbr = new node();
    return tbr;
} // End try allocation

catch(bad_alloc)
{
     throw OutOfMemoryException();
} // End catch(bad_alloc)
Run Code Online (Sandbox Code Playgroud)

c++ syntax compiler-errors visual-studio-2010 bad-alloc

1
推荐指数
1
解决办法
2073
查看次数