我在家学习C++,我使用的是rapidxml库。 我使用随附的说utils的打开文件:C++:Catch runtime_error
rapidxml::file<char> myfile (&filechars[0]);
我注意到,如果filechars
是错误的rapidxml::file
抛出runtime_error:
// Open stream
basic_ifstream<Ch> stream(filename, ios::binary);
if (!stream)
throw runtime_error(string("cannot open file ") + filename);
stream.unsetf(ios::skipws);
我想我需要写类似的东西:
try
{
rapidxml::file<char> GpxFile (pcharfilename);
}
catch ???
{
???
}
我做了一些google搜索,但我没有找到我需要在???
的地方。
有人能帮助我吗? 谢谢!
谢谢你的详细解答。我错过了catch块中的异常类型和它的用法。所以,如果很好理解,我会尝试:catch(const runtime_error&error){cout << error.what()<< endl; }'。 – Plouff