overflow_error 类
类用作。所有引发的异常的基类。报告算术溢出。
class overflow_error : public runtime_error {
public:
explicit overflow_error(const string& message);
explicit overflow_error(const char *message);
};
备注
exception 类 返回的值为 message.数据副本。
示例
// overflow_error.cpp
// compile with: /EHsc /GR
#include <bitset>
#include <iostream>
using namespace std;
int main( )
{
try
{
bitset< 33 > bitset;
bitset[32] = 1;
bitset[0] = 1;
unsigned long x = bitset.to_ulong( );
}
catch ( exception &e )
{
cerr << "Caught " << e.what( ) << endl;
cerr << "Type " << typeid( e ).name( ) << endl;
};
}
要求
页眉:<stdexcept>
命名空间: std