T
Tony Johansson
Hello experts!
I reading a book called programming with design pattern revealed
by Tomasz Muldner and here I read something that I find is wrong as I
believe.
An array index that is out of bounds in an array will not generate an
exception but will
generate the out_of_range exception if used in a vector(that is part of the
standard library)
Is this really true that out_of_range exception is generated if used in a
vector(that is part of the standard library)
I tried this but no exception was generated in this piece of code.
#inlude <vector>
#include <iostream>
int main()
{
try
{
vector<int> v(3);
cout << v[0];
cout << v[1];
cout << v[2];
cout << v[99];
}
catch (exception &e)
{
cout << exception occurred" << endl;
}
}
Many thanks
//Tony
I reading a book called programming with design pattern revealed
by Tomasz Muldner and here I read something that I find is wrong as I
believe.
An array index that is out of bounds in an array will not generate an
exception but will
generate the out_of_range exception if used in a vector(that is part of the
standard library)
Is this really true that out_of_range exception is generated if used in a
vector(that is part of the standard library)
I tried this but no exception was generated in this piece of code.
#inlude <vector>
#include <iostream>
int main()
{
try
{
vector<int> v(3);
cout << v[0];
cout << v[1];
cout << v[2];
cout << v[99];
}
catch (exception &e)
{
cout << exception occurred" << endl;
}
}
Many thanks
//Tony