Site hosted by Angelfire.com: Build your free website today!
// NotFound.cpp

/**
 * This class holds the definition of functions in the
 * exception class NotFound.
 *
 */



#include "NotFound.h"



// Returns message as a string

string NotFound::getMessage() const {

   if (i < 0)

      return "Your input was not found in the array.";

   else {

      int len = 1, t = i;

      if (t == 0)

         len++;

      while (t > 0) {

         len++;

         t /= 10;

      }

      char* temp = new char[len];

      temp[len-1] = '\0';

      t = i;

      for (int j = len-2, k = 1; j >= 0; j--, k *= 10)

         temp[j] = (i / k) % 10;

      string ret(temp);

      delete [] temp;

      return "Index " + ret + " not found.";

   }

}