/* 4. ´ÙÀ½ ÇÁ·Î±×·¥ÀÇ Ãâ·ÂÀ» ½á¶ó. */ #include int number[5] = { 1, 2, 3, 4, 5 }; // ¿©±â¸¦ ¹Ù²Ü °Í class Ex { int _x; public: Ex(int x) { _x = x; } int getX() { return _x; } }; class Test { int *_s; int _c; public: Test(int x[]) { _s = x; _c = 0; } void foo() { _s = _s + 1; if (_c > 2) throw "Shit !"; _c = _c + 1; int x = _s[0]; if (x/2*2 == x) { throw x; } else { throw new Ex(0); } } }; void main() { Test data(number); for(int i = 0; i < 5; i++) { try { printf("Hello !\n"); data.foo(); printf("World !\n"); } catch(int ex) { printf("%d\n",ex); } catch(char *ex) { printf("%s\n",ex); break; } catch(Ex *ex) { printf("%d\n",ex->getX()); } } }