C/C++
C++

C++ , , : <exception> <stdexcept>. . .

<exception>

<exception> , , . .

class exception {
public:
	exception() throw();
	exception(const bad_exception &ob) throw();
	virtual -exception() throw();
	exception &operator=(const exception &ob) throw();
	virtual const char *what(() const throw();
};

class bad_exception: public exception {
public:
	bad_exception() throw();
	bad_exception(const bad_exception &ob) throw();
	virtual ~bad_exception() throw();
	bad_exception &operator=(const bad_exception &ob) throw();
	virtual const char *what(() const throw();
};

exception - , C++. bad_exception , unexpected(). - what() , .

exception - , C++. bad_exception , unexpected(). - what() , .

exception . bad_alloc new. bad_typeid typeid. , bad_cast . , exception.

, <exception>.

terminate_handler typedef void(*terminate_handler)();
unexpected_handler  typedef void(*unexpected_handler)();

, <exception>.

terminate_handler set_terminate(terminate_handler fn) throw(); , fn, .
unexpected_handler set_unexpected(unexpected_handler fn) throw(); , fn, .
void terminate(); , . abort()
bool uncaught_exception(); true,
void unexpected(); , . terminate()

<stdexcept>

<stdexcept> , C++ / . , <stdexcept>: ( ). . - .

C++ , , logic_error. .

domain_error
invalid_argument 
length_error
out_of_range

runtime error.

overflow_error
range_error
underflow error 





2012-09-12 18:07:29 Ann

Вот еще примеры работы с исключениями: http://hashcode.ru/questions/135810/c-возможен-ли-вызов-исключения




Оставить комментарий:
Ваше Имя:
Email:
Антибот: *  
Ваш комментарий: