string msg1 = "Negative value";
string msg2 = "Zero value";
try
{
  infile >> value;
  do
  {
   if (value < 0)
     throw msg1;  // Exception is a string 
   else if (value = 0)
     throw msg2;  // Exception is a string
   sum = sum + value;
  }while (infile);
}

catch (string message)  
// Parameter of the catch is type string
{
  // Code that handles the exception
  cout << message << " found in file. Program aborted."
       << endl;
  return 1;
}
// Code to continue processing if exception not thrown. 
cout << "Sum of values on the file: " << sum << endl;

