19.3.1 try Block - Example

int main()
{
   bool more = true;
   while (more)
   {
      try
      {
         code
      }
      catch (logic_error& e)
      {
         cout << "A logic error has occurred: "
            << e.what() << "\n" << "Retry? (y/n)";
         string input;
         getline(cin, input);
         if (input == "n") more = false;
      }
   }
}

prev |top |next