首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

try catch(exception * ex)怎么使用

2012-03-09 
try catch(exception * ex)如何使用?请问,这个怎么用?我这么写,Dev-cpp可以编译,但是无法运行。#includecs

try catch(exception * ex)如何使用?
请问,这个怎么用?
我这么写,Dev-cpp可以编译,但是无法运行。

#include   <cstdlib>
#include   <iostream>

class   MyExc{
public:
void   f(){
std::cout < < "...\n ";
}
};

int   main(int   argc,   char   *argv[])
{
try{
throw   MyExc();
}
catch(MyExc*   me){
std::cout < < "Error\n ";
}
system( "PAUSE ");
        return   0;
}


返回错误
This   application   has   requested   the   Runtime   to   terminate   it   in   an   unusual   way.
Please   contact   the   application 's   support   team   for   more   information.

[解决办法]
try{
throw MyExc();
}
catch(MyExc& me){
std::cout < < "Error\n ";
}
[解决办法]
楼上可以

try{
throw MyExc();
}
catch(MyExc me){
std::cout < < "Error\n ";
}
也可

热点排行