invalid_argument
描述 (Description)
它是一个无效的参数异常,该类定义了作为异常报告无效参数的对象类型。
声明 (Declaration)
以下是std :: invalid_argument的声明。
class invalid_argument;
C++11
class invalid_argument;
参数 (Parameters)
没有
返回值 (Return Value)
没有
成员 (Members)
constructor - 这里作为what_arg传递的字符串与成员返回的值具有相同的内容。
例子 (Example)
在下面的示例中为std :: invalid_argument。
#include <iostream>
#include <stdexcept>
#include <bitset>
#include <string>
int main (void) {
try {
std::bitset<5> mybitset (std::string("01203040"));
} catch (const std::invalid_argument& ia) {
std::cerr << "Invalid argument: " << ia.what() << '\n';
}
return 0;
}
输出应该是这样的 -
Invalid argument: bitset::_M_copy_from_ptr