Witam,
mam pytanie odnośnie kodu
// using standard exceptions
#include <iostream>
#include <exception>
using namespace std;
class myexception: public exception
{
virtual const char* what() const throw()
{
return "My exception happened";
}
} myex;
int main () {
try
{
throw myex;
}
catch (exception& e)
{
cout << e.what() << '\n';
}
return 0;
}
dokładnie tej linijki
virtual const char* what() const throw()
Po co używana jest funkcja throw()? To nie jest jakiś rodzaj definiowania funkcji tylko to jest element języka C++(wyjątki) tzn nie można stworzyć takiej konstrukcji np
int funkcja1() const funkcja2()
?