functexcept中有一个函数__throw_out_of_range 只有声明,找不到它的定义
而且特别奇怪
#include <iostream>
#include <typeinfo>
using namespace std;
int main()
{
try
{
__throw_out_of_range("out_of_range");
}
catch(out_of_range &err)
{
cout<<typeid(err).name()<<endl;
}
return 0;
}
我这样写的话,当然会编译错误,因为没#include <stdexcept>
会得到[Error] 'out_of_range' does not name a type
因为out_of_range是在stdexcept中定义的一个类,也就是我的程序中没有它的定义
但是
#include <iostream>
#include <typeinfo>
using namespace std;
int main()
{
try
{
__throw_out_of_range("out_of_range");
}
catch(exception &err)
{
cout<<typeid(err).name()<<endl;
}
return 0;
}
我这样的话会输出St12out_of_range
也就是我确实是捕获到它了,所以很奇怪,怎么能捕获到一个没有声明过的对象呢
__throw_out_of_range这个函数太奇怪了