StupidBeauty
Read times:1199Posted at:Sat Nov 12 21:33:55 2011

std::bad_alloc

这是C++标准库中的一个类,继承自std::exception,表示的是内存分配失败这个异常。

如果想要捕获内存分配失败的异常,就:

try //可能抛出异常。

{

ApplySession(); //让会话的内容生效。

} //try

catch ( std :: bad_alloc & BadAlloc) //捕捉内存分配失败的异常。

{

ui -> MainStackedWidget ->setCurrentWidget( ui -> ErrorPage ); //转到错误页面。

ui -> ErrorReasonLabel ->setText(tr( "No enough memory." )); //内存不够。

} //catch

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands