0
我想測試訪問字符串中的元素是否超出範圍。我知道如何捕捉(標準:: out_of_range),但什麼即時試圖做的是,如果(out_of_range) 例子:測試超出範圍
string test;
int a;
test="123456789";
if(test.at(9)==out_of_range) //this isnt proper code but this is what im trying to accomplish
{
a=0;}
else
a=1;
我編程在C++ VS10
例外必須被捕獲。函數拋出的異常與其正常返回類型完全分離並與其無關。這就是爲什麼你不能用'if(function()== exception)'檢查它。 – us2012
我一問就知道我要做什麼,我覺得自己像一個白癡大聲笑 – user2840470