logic_error Class

클래스는 논리적 사전 조건이 위반 같은 프로그램을 실행 하기 전에 아마도 검색 보고서 오류가 throw 된 모든 예외에 대 한 기본 클래스 역할을 합니다.

class logic_error : public exception {
public:
    explicit logic_error(const string& message);
    explicit logic_error(const char *message);
};

설명

반환 값 exception Class 의 복사본 인 메시지.데이터.

예제

// logic_error.cpp
// compile with: /EHsc /GR
#include <iostream>
using namespace std;

int main( )
{
   try 
   {
      throw logic_error( "logic error" );
   }
   catch ( exception &e ) 
   {
      cerr << "Caught: " << e.what( ) << endl;
      cerr << "Type: " << typeid( e ).name( ) << endl;
   };
}

Output

Caught: logic error
Type: class std::logic_error

요구 사항

헤더: <stdexcept>

네임 스페이스: std

참고 항목

참조

exception Class

표준 C++ 라이브러리에서 스레드로부터의 안전성