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 ";
}
也可