The runtime_error C++ exception usage showing the bad local name
Compiler: Visual C++ Express Edition 2005
Compiled on Platform: Windows XP Pro SP2
Header file: Standard
Additional project setting: Set project to be compiled as C++
Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)
Other info:
To do: Catching the bad local name for the runtime_error C++ program example
To show: The runtime_error C++ exception program example showing how to catch the bad local name
// runtime_error
#include <iostream>
using namespace std;
int main(void)
{
// runtime_error
try
{
locale testlocale("Something");
}
catch(exception &err)
{
cerr<<"Caught "<<err.what()<<endl;
cerr<<"Type "<<typeid(err).name()<<endl;
};
}
Output example:
Caught bad locale name
Type class std::runtime_error
Press any key to continue . . .