C ++: weird syntax in what () method std :: exception

When I inherit from std::exceptionto define my own exception type, I need to override a method what()that has the following signature:

virtual const char* what() const throw();

It definitely looks strange to me, as if there were two method names in the signature. This is some very specific syntax, for example, using pure virtual methods, for example:

virtual int method() const = 0;

or is it a function that can be used in some other way in another context? And if so, what can it be used for?

+3
source share
3 answers

exception specifications. throw() throw(int) int.

++ 0x. .

+12
virtual const char* what() const throw();

what() - , const char . :)

+1

ios_base failure. , /.

exception.

failure :

explicit failure(const string &str);

str - , .

failure, what(), :

virtual const char *what( ) const throw( );
-1
source

Source: https://habr.com/ru/post/1746999/


All Articles