Brand new to C++
cout << "Hello World!" << endl;
int x = 0;
cout << "Enter your favorite number: ";
try
{
cin >> x;
}
catch (int e)
{
cout << "Hey dummy, enter a number!" << endl;
}
cout << x << "? That's a pretty small number. \nI bet that's the highest you can count." << endl;
string mystring;
// Made possible by <string>
cout << "Tell us your name: ";
getline (cin, mystring);
cout << "Hello " << mystring << endl;If I delete the following code my program runs fine. So what's wrong with my try/catch statement?
try
{
cin >> x;
}
catch (int e)
{
cout << "Hey dummy, enter a number!" << endl;
}-Nothing to see. Move along.