stoi
(“string to integer”)
in
bmi.C
to convert a
string
to an
int.
throw.C
c++ throw.C ./a.out terminate called after throwing an instance of 'std::invalid_argument' what(): stoi Aborted (core dumped) echo $? (See the exit status.) 134 (It didn't return EXIT_SUCCESS or EXIT_FAILURE.)
stoi
throws an object of class
exception.
what
member function.
...,
the most general one of all.
catch.C,
catch.txt
c++ throw.C ./a.out Not a valid integer stoi echo $? (See the exit status.) 1 (It returned a civilized EXIT_FAILURE.)With the argument
"2147483648",
the output will be
Value out of range stoi
new
operator can throw two different types of exceptions.
new.C,
new.txt
nothrow.C,
nothrow.txt