M
mos
Hi!
When call a null function pointer will cause a execption, but it can't
be caught as std::exception, then which exception it is?
The following code is a example:
typedef void (*testfunc)(int a);
void test()
{
testfunc func = NULL;
func(10);
iTest* p = NULL;
p->Test(10);
}
int main()
{
try
{
test();
}
catch(std::exception& x)
{
std::cout << "exception: " << x.what() << std::endl;
}
catch(...)
{
std::cout << "unknown" << std::endl;
}
return 0;
}
When call a null function pointer will cause a execption, but it can't
be caught as std::exception, then which exception it is?
The following code is a example:
typedef void (*testfunc)(int a);
void test()
{
testfunc func = NULL;
func(10);
iTest* p = NULL;
p->Test(10);
}
int main()
{
try
{
test();
}
catch(std::exception& x)
{
std::cout << "exception: " << x.what() << std::endl;
}
catch(...)
{
std::cout << "unknown" << std::endl;
}
return 0;
}