次の方法で共有


invalid_argument Class

クラスは、無効な引数を報告するためにスローされたすべての例外の基本クラスとして機能します。

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

解説

exception Class によって返される値は、message.データのコピーです。

使用例

// invalid_arg.cpp
// compile with: /EHsc /GR
#include <bitset>
#include <iostream>

using namespace std;

int main( )
{
   try 
   {
      bitset< 32 > bitset( string( "11001010101100001b100101010110000") );
   }
   catch ( exception &e ) 
   {
      cerr << "Caught " << e.what( ) << endl;
      cerr << "Type " << typeid( e ).name( ) << endl;
   };
}
  

必要条件

Header: <stdexcept>

名前空間: std

参照

関連項目

logic_error Class

C++ の標準ライブラリのスレッド セーフ