64,682
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
void recoup (int) throw (std ::runtime_error)
{
throw std ::runtime_error("runtime_error") ;
}
int _tmain(int argc, _TCHAR* argv[])
{
void (* pF) (int) throw() = recoup ;
return 0 ;
}
#include "stdafx.h"
#include <iostream>
class Base
{
public:
virtual void fun (void) throw () {}
} ;
class Dirived: public Base
{
public:
void fun (void) throw (std ::underflow_error)
{
throw std ::underflow_error("underflow_error") ;
}
} ;
int _tmain(int argc, _TCHAR* argv[])
{
Base base ;
Dirived dirived ;
Base * pBase = &dirived ;
try
{
pBase ->fun() ;
}
catch (std ::underflow_error & uErr)
{
std ::cout << uErr.what() << std ::endl ;
}
std ::cin.get() ;
return 0 ;
}
同样可以编译通过,运行也没问题,为什么?