分享方式:


underflow_error 類別

此類別可做為擲回之所有例外狀況的基底類別,這些例外狀況報告算術反向溢位。

語法

class underflow_error : public runtime_error {
public:
    explicit underflow_error(const string& message);

    explicit underflow_error(const char *message);

};

備註

what() 回的值是 的 message.data() 複本。 如需詳細資訊,請參閱 whatdata

underflow_error 不會由 Microsoft 實作 C++ 標準程式庫中的任何函式擲回,但可能會由協力廠商程式庫或使用者程式碼擲回。

範例

// underflow_error.cpp
// compile with: /EHsc
#include <exception>
#include <iostream>
#include <stdexcept>
#include <typeinfo>
using namespace std;

int main()
{
   try
   {
      throw underflow_error("The number's a bit small, captain!");
   }
   catch (const exception& e)
   {
      cerr << "Caught: " << e.what() << endl;
      cerr << "Type: " << typeid(e).name() << endl;
   }
}
/* Output:
Caught: The number's a bit small, captain!
Type: class std::underflow_error
*/

需求

Header: < stdexcept>

命名空間:std

另請參閱

runtime_error 類別
C++ 標準程式庫中的執行緒安全