标签:基本原则 pac http VS2017 turn include error img 不同
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include<string.h> using namespace std; void testerror(int x,int y) { if (y==0) { throw x; } cout << "计算结果:"<<x/y<< endl; } void main() { try { testerror(100,0); } catch (int x) { cout << x << "不能被0整除" << endl; } catch (...) { cout << "无言的结局" << endl; } system("pause"); }
void testerror(int x,int y) { if (y==0) { throw x; } cout << "计算结果:"<<x/y<< endl; } void awrap() { testerror(100, 0); } void main() { // try { awrap(); } catch (int x) { cout << x << "不能被0整除" << endl; } catch (...) { cout << "无言的结局" << endl; } system("pause"); }
输出结果:
void testerror(char * name) { cout << "his name is " << name << endl; if (name=="雨化田") { throw name; } cout << "原来是:"<<name<<"!快快进来享用广式炒面"<< endl; } int main() { // char name[] = "雨化田"; char *hisname = name; try { testerror(hisname); } catch (char *name) { cout << "妈爷子诶~这不是:" << name << endl; } catch (...) { cout << "无言的结局" << endl; } system("pause"); return 0; }
输出结果:看来并未按照我们的意愿去处理
标签:基本原则 pac http VS2017 turn include error img 不同
原文地址:https://www.cnblogs.com/saintdingspage/p/12079491.html