Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > deriving from std::exception

Reply
Thread Tools

deriving from std::exception

 
 
Noah Roberts
Guest
Posts: n/a
 
      07-31-2003
I am having some problems with deriving the std::exception class. My
compiler (g++-2.95) works with it just fine, but it does in a lot of
broken cases. I have a user/developer that can't compile the following
code:

class CFENException : public std::exception
{
std::string _what;

public:
CFENException(std::string what) : _what(what) {}
virtual const char* what() const throw() { return _what.c_str(); }
};

He is getting the following error from dev-c++ 4.9.8.1:
line 57 in BitBoard.h: looser throw specifier for 'virtual
line 54 in exception: overriding 'virtual

Isn't throw() the tightest specifier you can get? It says this method
cannot throw anything right?

My book on the c++ std, The C++ Standard Library by Josuttis, says the
above is the correct way to derive the exception class. So WTF am I
doing wrong if anything?

Thanks for any help,
NR

 
Reply With Quote
 
 
 
 
Alexander Terekhov
Guest
Posts: n/a
 
      07-31-2003

Noah Roberts wrote:
>
> I am having some problems with deriving the std::exception class. My
> compiler (g++-2.95) works with it just fine, but it does in a lot of
> broken cases. I have a user/developer that can't compile the following
> code:
>
> class CFENException : public std::exception
> {
> std::string _what;
>
> public:
> CFENException(std::string what) : _what(what) {}


Add ~CFENException() throw() {}

> virtual const char* what() const throw() { return _what.c_str(); }


what() is brain-damaged.

> };


Almost the entire C++ EH just sucks miserably, BTW.

regards,
alexander.
 
Reply With Quote
 
 
 
 
Alexander Terekhov
Guest
Posts: n/a
 
      07-31-2003

"Alf P. Steinbach" wrote:
[...]
> And possibly also mail a bug-report ...


http://google.com/groups?threadm=3EC...0B266%40web.de
(Subject: Exception handling... it's time to fix the standard)

"I believe that ALL dtors shall have an implicit throw()-
nothing exception-spec imposed on them. "

regards,
alexander.
 
Reply With Quote
 
Greg P.
Guest
Posts: n/a
 
      08-01-2003
"Alf P. Steinbach" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| I very much doubt it. If it really does, please post some quote
| here. And possibly also mail a bug-report to the author.
What page(s) is this on?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deriving from MembershipUser and ASPNET Config Tool Mark Olbert ASP .Net 9 01-20-2006 07:59 AM
Problem deriving from WebControl Class Gary Rynearson ASP .Net 0 11-18-2005 03:34 PM
deriving from textbox control Lisa Calla ASP .Net 3 10-22-2004 06:16 PM
Problem in deriving custome class from XmlNode Mahesh Devjibhai Dhola ASP .Net 0 10-15-2004 07:38 AM
deriving RandomAccessFile? Mike Java 0 06-28-2003 10:50 AM



Advertisments