I am trying to write a getter function from my class, which would return a part of my member variable vector<short>:
And I try to test it with an out of range value for int index:Code:const vector<short> Input::getOneRow(int index) const
{
try
{
return values.at(index);
}
catch(const out_of_range &e)
{
cerr << "Out of range " << endl;
}
}
What happens is that the exception is caught, the error message is printed, but then when my program crashes with some unknown error. Why? What happens?Code:int main()
{
/* ... declare myClass ... */
vector<short> test2 = myClass.getOneRow(555);
}