View Full Version : Destructor for Qtconcurrent::Exception?

20th September 2011, 03:18
I am deriving an exception class from Qtconcurrent::Exception, and am receiving a compilation error

looser throw specifier for 'virtual SException::~SException()'
overriding 'virtual QtConcurrent::Exception::~Exception() throw()'
The class is as follows

class SException : public QtConcurrent::Exception
SException(const QString& message) : message_(message) {}
void raise() const { throw *this; }
Exception *clone() const { return new SException(*this); }
QString message() const { return message_; }

QString message_;
How do you specify the destructor correctly? I have already tried specifying a virtual destructor in the derived class but still get the same error.

20th September 2011, 04:10
Did you specify throw() for your destructor?

20th September 2011, 15:39
When I add the destructor

virtual ~SException() throw();
the compiler error goes away, but now I get a linking error looking for the implementation of the SException destructor.

What is the difference between

virtual ~SException() throw();

virtual ~SException() { throw(); }

20th September 2011, 16:06
You get a linker error because you didn't implement a destructor that contains a throw declaration. If you declare a method with throw(), you need to implement a method with throw().

About your question -- the difference is like between a bucket of water and an apple.

20th September 2011, 19:25
Thanks, I figured out what throw() does and I added an implementation to the destructor.