invalid_argument 클래스

이 클래스는 잘못된 인수를 보고하기 위해 발생하는 모든 예외에 대한 기본 클래스로 사용됩니다.

구문

class invalid_argument : public logic_error {
public:
    explicit invalid_argument(const string& message);

    explicit invalid_argument(const char *message);

};

설명

반환되는 what() 값은 .의 message.data()복사본입니다. 자세한 내용은 whatdata를 참조하세요.

예시

// 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
*/

요구 사항

헤더:<stdexcept>

네임스페이스: std

참고 항목

logic_error 클래스
C++ 표준 라이브러리의 스레드 보안