博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VC++异常捕获??
阅读量:7164 次
发布时间:2019-06-29

本文共 921 字,大约阅读时间需要 3 分钟。

1、

std:

1 #include 
2 #include
// for cerr 3 //#include
// for what ? 4 using namespace std; 5 6 7 int _tmain(int argc, _TCHAR* argv[]) 8 { 9 string s1("UIPower");10 char chA = s1[2];11 12 try13 {14 char chD = s1.at(300);15 }16 catch(...)17 {18 printf("err\n");19 }20 21 printf("\n");22 try23 {24 char chD = s1.at(300);25 }26 catch(std::out_of_range &ex)27 {28 std::cerr << ex.what() << " Line:" << __LINE__ << " File:" << __FILE__ << endl;29 }30 31 printf("\n");32 try33 {34 char chD = s1.at(300);35 }36 catch(std::exception &ex)37 {38 std::cerr << ex.what() << " Line:" << __LINE__ << " File:" << __FILE__ << endl;39 }40 41 system("pause");42 return 0;43 }

 

2、

 

C

 

转载于:https://www.cnblogs.com/CodeSkill/p/5162952.html

你可能感兴趣的文章