CPlusPlusThings/practical_exercises/10_day_practice/day9/异常例子/1.cpp
Light-City a4d828bb4c update
2020-04-06 00:57:02 +08:00

20 lines
480 B
C++

//Eg10-1.cpp
#include<iostream>
using namespace std;
int main(){
cout<<"1--befroe try block..."<<endl;
try{
cout<<"2--Inside try block..."<<endl;
throw 10;
cout<<"3--After throw ...."<<endl;
}
catch(int i) {
cout<<"4--In catch block1 ... exception..errcode is.."<<i<<endl;
}
catch(char * s) {
cout<<"5--In catch block2 ... exception..errcode is.."<<s<<endl;
}
cout<<"6--After Catch...";
system("pause");
}