Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

HP C++ User Documentation

 

underflow_error (3C++std) - Tru64 UNIX

Standard C++ Library
Copyright 1996, Rogue Wave Software, Inc.

NAME

  exception,logic_error,domain_error,invalid_argument,length_error,
  out_of_range,runtime_error,range_error,overflow_error,underflow_error  -
  Classes supporting logic and runtime errors.

SYNOPSIS

   #include <exception>

  class exception;

DESCRIPTION

  The class exception defines the base class for the types of objects thrown
  as exceptions by Standard C++ Library components, and certain expressions,
  to report errors detected during program execution.  Users can also use
  these exceptions to report errors in their own programs.

INTERFACE

  class exception {

    public:
      exception () throw();
      exception (const exception&) throw();
      exception& operator= (const exception&) throw();
      virtual ~exception () throw();
      virtual const char* what () const throw();
   };

  class logic_error : public exception {
    public:
      logic_error (const string& what_arg);
   };

  class domain_error : public logic_error {
    public:
      domain_error (const string& what_arg);
   };

  class invalid_argument : public logic_error {
    public:
      invalid_argument (const string& what_arg);
   };

  class length_error : public logic_error {
    public:
      length_error (const string& what_arg);
   };

  class out_of_range : public logic_error {
    public:
      out_of_range (const string& what_arg);
   };

  class runtime_error : public exception {
    public:
      runtime_error (const string& what_arg);
   };

  class range_error : public runtime_error {
    public:
      range_error (const string& what_arg);
   };

  class overflow_error : public runtime_error {
    public:
      overflow_error (const string& what_arg);
   };

  class underflow_error : public runtime_error {
    public:
      underflow_error (const string& what_arg);
   };

CONSTRUCTORS

  exception()
  throws();
     Constructs an object of class exception.

  exception(const exception&)
  throws();
     The copy constructor.  Copies an exception object.

DESTRUCTOR

  virtual
  ~exception()
  throws();
     Destroys an object of class exception.

OPERATORS

  exception&
  operator=(const exception&)
  throws();
     The assignment operator.  Copies an exception object.

MEMBER FUNCTION

  virtual const char*
  what()const
  throws();
     Returns an implementation-defined, null-terminated byte string
     representing a human-readable message describing the exception.  The
     message may be a null-terminated multibyte string, suitable for
     conversion and display as a wstring.

CONSTRUCTORS FOR DERIVED CLASSES

  logic_error::logic_error(const string& what_arg);
     Constructs an object of class logic_error.

  domain_error::domain_error(const string& what_arg);
     Constructs an object of class domain_error.

  invalid_argument::invalid_argument(const string& what_arg);
     Constructs an object of class invalid_argument.

  length_error::length_error(const string& what_arg);
     Constructs an object of class length_error.

  out_of_range::out_of_range(const string& what_arg);
     Constructs an object of class out_of_range.

  runtime_error::runtime_error(const string& what_arg);
     Constructs an object of class runtime_error.

  range_error::range_error(const string& what_arg);
     Constructs an object of class range_error.

  overflow_error::overflow_error(const string& what_arg);
     Constructs an object of class overflow_error.

  underflow_error::underflow_error(
                     const string& what_arg);
                        Constructs an object of class underflow_error.

EXAMPLE

    //
    // exception.cpp
    //
    #include <iostream.h>
    #include <stdexcept>

   static void f() { throw runtime_error("a runtime error"); }

   int main ()
    {
       //
       // By wrapping the body of main in a try-catch block
       // we can be assured that we'll catch all exceptions
       // in the exception hierarchy.  You can simply catch
       // exception as is done below, or you can catch each
       // of the exceptions in which you have an interest.
       //
      try
       {
          f();
       }
      catch (const exception& e)
       {
          cout << "Got an exception: " << e.what() << endl;
       }
      return 0;
    }

STANDARDS CONFORMANCE

  ANSI X3J16/ISO WG21 Joint C++ Committee
About PDF files: The PDF files on this site can be read online or printed using Adobe® Acrobat® Reader. If you do not have this software on your system, you may download it from Adobe's website.
Privacy statement Using this site means you accept its terms C++ support
© 2008 Hewlett-Packard Development Company, L.P.