invalid_argument 類別
此類別可做為擲回之所有例外狀況的基底類別,這些例外狀況報告無效的引數。
語法
class invalid_argument : public logic_error {
public:
explicit invalid_argument(const string& message);
explicit invalid_argument(const char *message);
};
備註
傳 what()
回的值是 的 message.data()
複本。 如需詳細資訊,請參閱 what
和 data
。
範例
// invalid_argument.cpp
// compile with: /EHsc
#include <bitset>
#include <exception>
#include <iostream>
#include <typeinfo>
using namespace std;
int main()
{
try
{
bitset<32> b("11001010101100001b100101010110000");
}
catch (const exception& e)
{
cerr << "Caught: " << e.what() << endl;
cerr << "Type: " << typeid(e).name() << endl;
}
}
/* Output:
Caught: invalid bitset char
Type: class std::invalid_argument
*/
需求
Header: < stdexcept>
命名空間:std
另請參閱
意見反映
https://aka.ms/ContentUserFeedback。
即將推出:我們會在 2024 年淘汰 GitHub 問題,並以全新的意見反應系統取代並作為內容意見反應的渠道。 如需更多資訊,請參閱:提交及檢視以下的意見反映: