I'm trying to print the type name using exceptions, but my program doesn't even seem to catch the exception and instead seems to call the default termination function. What have I missed?
#include <cstdio>
#include <exception>
#include <typeinfo>
namespace Error
{
template<typename T>
class Blah : std::exception
{
virtual const char* what() const throw()
{
return typeid(T).name();
}
};
}
void blah() {
throw Error::Blah<int*********>();
}
int main()
{
try
{
blah();
}
catch (std::exception& e)
{
std::puts(e.what());
}
}