SlideShare a Scribd company logo
1 of 8
Download to read offline
C++ !
http://blog.naver.com/ruvendix
새로운 예외 처리의 필요성
예외 처리를 선택문으로만 하려고 하니까 복잡하다…
좀 더 편하면서 직관적인 예외 처리가 없을까…?
좋아! 새로운 예외 처리를 만들어서 문법으로 적용하자!
http://blog.naver.com/ruvendix
try throw catch
try와 catch는 무조건 같이 따라다님!
throw는 catch로 예외 객체를 던짐!
catch는 throw가 던진
예외 객체를 보고 예외 처리를 함!
http://blog.naver.com/ruvendix
스택 되감기
try ~ catch문은 호출된 구조를 거꾸로
올라가면서 예외를 처리한다!
void Func(void)
{
throw 1;
}
try
{
Func();
}
catch (int)
{
// 예외 처리
}
이렇게 거꾸로 올라가려면
함수가 호출된 이전 상황으로
만들어야 하는데 그걸
스택 되감기라고 함!
http://blog.naver.com/ruvendix
예외 처리 전용 클래스
class CException
{
void ShowError(void);
}
try
{
throw CException;
}
catch (CException &rE)
{
// 예외 처리
}
예외를 처리하는 클래스를
따로 만들면 좀 더 편하게
예외 처리를 할 수 있음!
http://blog.naver.com/ruvendix
예외 처리 선언
int Add(int iNum1, int iNum2) throw () // 예외 처리할 대상이 없다!
{
return (iNum1 + iNum2);
}
int Div(int iNum1, int iNum2) throw (int) // 예외 처리할 대상은 int
{
if (iNum2 == 0)
{
throw iNum2;
}
return (iNum1 / iNum2);
}
http://blog.naver.com/ruvendix
표준 예외 처리
이미 만들어진 예외 처리를 이용할 수도 있다!
exception에는 what()이라는 메서드가 있는데
이 메서드를 이용하면 오류 내용을 볼 수 있음!
http://blog.naver.com/ruvendix

More Related Content

What's hot

이펙티브 C++ 공부
이펙티브 C++ 공부이펙티브 C++ 공부
이펙티브 C++ 공부quxn6
 
More effective c++ 2
More effective c++ 2More effective c++ 2
More effective c++ 2현찬 양
 
M1 2 1
M1 2 1M1 2 1
M1 2 1nexthw
 
이펙티브 C++ 5,6 장 스터디
이펙티브 C++ 5,6 장 스터디이펙티브 C++ 5,6 장 스터디
이펙티브 C++ 5,6 장 스터디quxn6
 
Hello c++ world
Hello c++ worldHello c++ world
Hello c++ world. Ruvendix
 
Ec++ c 1,2 surmary
Ec++ c 1,2 surmaryEc++ c 1,2 surmary
Ec++ c 1,2 surmarySehyeon Nam
 
자바와 사용하기2
자바와 사용하기2자바와 사용하기2
자바와 사용하기2destinycs
 
JavaScript Patterns - Chapter 3. Literals and Constructors
JavaScript Patterns - Chapter 3. Literals and ConstructorsJavaScript Patterns - Chapter 3. Literals and Constructors
JavaScript Patterns - Chapter 3. Literals and ConstructorsHyuncheol Jeon
 
Effective c++ 4
Effective c++ 4Effective c++ 4
Effective c++ 4현찬 양
 
More effective c++ 3
More effective c++ 3More effective c++ 3
More effective c++ 3현찬 양
 
More effective c++ 1
More effective c++ 1More effective c++ 1
More effective c++ 1현찬 양
 
이펙티브 C++ 스터디
이펙티브 C++ 스터디이펙티브 C++ 스터디
이펙티브 C++ 스터디quxn6
 
More effective c++ 항목30부터
More effective c++ 항목30부터More effective c++ 항목30부터
More effective c++ 항목30부터Dong Chan Shin
 
Effective c++ chapter 1,2 요약
Effective c++ chapter 1,2 요약Effective c++ chapter 1,2 요약
Effective c++ chapter 1,2 요약Nam Hyeonuk
 
Effective c++ 정리 1~2
Effective c++ 정리 1~2Effective c++ 정리 1~2
Effective c++ 정리 1~2Injae Lee
 

What's hot (20)

이펙티브 C++ 공부
이펙티브 C++ 공부이펙티브 C++ 공부
이펙티브 C++ 공부
 
More effective c++ 2
More effective c++ 2More effective c++ 2
More effective c++ 2
 
M1 2 1
M1 2 1M1 2 1
M1 2 1
 
이펙티브 C++ 5,6 장 스터디
이펙티브 C++ 5,6 장 스터디이펙티브 C++ 5,6 장 스터디
이펙티브 C++ 5,6 장 스터디
 
Hello c++ world
Hello c++ worldHello c++ world
Hello c++ world
 
Ec++ c 1,2 surmary
Ec++ c 1,2 surmaryEc++ c 1,2 surmary
Ec++ c 1,2 surmary
 
자바와 사용하기2
자바와 사용하기2자바와 사용하기2
자바와 사용하기2
 
JavaScript Patterns - Chapter 3. Literals and Constructors
JavaScript Patterns - Chapter 3. Literals and ConstructorsJavaScript Patterns - Chapter 3. Literals and Constructors
JavaScript Patterns - Chapter 3. Literals and Constructors
 
Effective c++ 4
Effective c++ 4Effective c++ 4
Effective c++ 4
 
More effective c++ 3
More effective c++ 3More effective c++ 3
More effective c++ 3
 
More effective c++ 1
More effective c++ 1More effective c++ 1
More effective c++ 1
 
이펙티브 C++ 스터디
이펙티브 C++ 스터디이펙티브 C++ 스터디
이펙티브 C++ 스터디
 
More effective c++ 항목30부터
More effective c++ 항목30부터More effective c++ 항목30부터
More effective c++ 항목30부터
 
Effective c++ chapter 1,2 요약
Effective c++ chapter 1,2 요약Effective c++ chapter 1,2 요약
Effective c++ chapter 1,2 요약
 
javascript01
javascript01javascript01
javascript01
 
Mec 56
Mec 56Mec 56
Mec 56
 
C++11 1
C++11 1C++11 1
C++11 1
 
Effective c++ 정리 1~2
Effective c++ 정리 1~2Effective c++ 정리 1~2
Effective c++ 정리 1~2
 
5 6 1
5 6 15 6 1
5 6 1
 
01. basic types
01. basic types01. basic types
01. basic types
 

Viewers also liked

Viewers also liked (19)

형식 선정
형식 선정형식 선정
형식 선정
 
템플릿
템플릿템플릿
템플릿
 
상속과 다형성
상속과 다형성상속과 다형성
상속과 다형성
 
클래스의 기초 지식
클래스의 기초 지식클래스의 기초 지식
클래스의 기초 지식
 
전처리기
전처리기전처리기
전처리기
 
배열
배열배열
배열
 
동적할당
동적할당동적할당
동적할당
 
구조체
구조체구조체
구조체
 
포인터
포인터포인터
포인터
 
자료형과 값
자료형과 값자료형과 값
자료형과 값
 
Triple E - Corporate Profile
Triple E - Corporate ProfileTriple E - Corporate Profile
Triple E - Corporate Profile
 
Instructivo acuartelamiento no.3
Instructivo acuartelamiento no.3Instructivo acuartelamiento no.3
Instructivo acuartelamiento no.3
 
Practica gen 5 marzo-2017
Practica gen 5 marzo-2017Practica gen 5 marzo-2017
Practica gen 5 marzo-2017
 
표준 입출력
표준 입출력표준 입출력
표준 입출력
 
Положение о Sanker Cup 2016
Положение о Sanker Cup 2016Положение о Sanker Cup 2016
Положение о Sanker Cup 2016
 
Shoot the Shit - Estúdio Criativo de Comunicação
Shoot the Shit - Estúdio Criativo de ComunicaçãoShoot the Shit - Estúdio Criativo de Comunicação
Shoot the Shit - Estúdio Criativo de Comunicação
 
МГЛК сезона 2016-2017 - 4-й этап - 19.03.2017 официальные результаты
МГЛК сезона 2016-2017 - 4-й этап - 19.03.2017 официальные результатыМГЛК сезона 2016-2017 - 4-й этап - 19.03.2017 официальные результаты
МГЛК сезона 2016-2017 - 4-й этап - 19.03.2017 официальные результаты
 
"Gurabo Tierra de Combate".
"Gurabo Tierra de Combate". "Gurabo Tierra de Combate".
"Gurabo Tierra de Combate".
 
Internet Safety Aisa
Internet Safety AisaInternet Safety Aisa
Internet Safety Aisa
 

예외 처리