out_of_range Class

选件类用作对于所有引发异常的基类。报告超出数组的有效范围的参数。

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

备注

exception Class 返回的值是 消息.数据的副本。

示例

// out_of_range.cpp
// compile with: /EHsc
#include <string>
#include <iostream>

using namespace std;

int main() {
// out_of_range
   try {
      string str( "Micro" );
      string rstr( "soft" );
      str.append( rstr, 5, 3 );
      cout << str << endl;
   }
   catch ( exception &e ) {
      cerr << "Caught: " << e.what( ) << endl;
   };
}

Output

Caught: invalid string position

要求

Header: <stdexcept>

命名空间: std

请参见

参考

logic_error Class

线程安全性对标准C++库中