www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/19/11:26:24

Message-ID: <2F5D18165CB1D2119E0D00805F65BBC80496D3B1@newhampshire.exchange.indiana.edu>
From: "Johnson, Nate" <natjohns AT indiana DOT edu>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: Exception Handling
Date: Wed, 19 Jul 2000 07:51:17 -0500
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp AT delorie DOT com

i havent used djgpp in awhile, but when i used "user defined" exceptions in
msvc i always use the new operator when using exceptions, like this...

   throw new exception("Error message here");

nate j.

-----Original Message-----
From: Dogansmoobs [mailto:dogansmoobsNOdoSPAM AT hotmail DOT com DOT invalid]
Sent: Tuesday, July 18, 2000 3:37 PM
To: djgpp AT delorie DOT com
Subject: Exception Handling


I am having a problem with exception handling.  Whenever I try
to cathch and exception, instead of running what's in the catch
block, it exits the program and displays Abort!!.  Is there
something I'm missing, or doing wrong??  Here's what I'm doing:

#include <iosteam>

class exception
{
 public:
   exception(char *message)
   {
    strcpy(errorMessage, message);
   }

   void display()
   {
    cout << errorMessage;
   }

 private:
   char *errorMessage;
};

Then whin I want to throw an exception, I say:
   throw exception("Error message here");

and then catch it using:
   catch (exception &e)

but it never does this, it just aborts.  And yes, the code that
produces the exception is in a try block.

 - Dogansmoobs
http://wookie.freehosting.net/
I would call myself Duncan Blownuts, but people might think I'm
insane.


-----------------------------------------------------------

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019