Destructor for Qtconcurrent::Exception?
I am deriving an exception class from Qtconcurrent::Exception, and am receiving a compilation error
Quote:
looser throw specifier for 'virtual SException::~SException()'
overriding 'virtual QtConcurrent::Exception::~Exception() throw()'
The class is as follows
Code:
class SException : public QtConcurrent::Exception
{
public:
SException(const QString& message) : message_(message) {}
void raise() const { throw *this; }
Exception *clone() const { return new SException(*this); }
QString message
() const { return message_;
}
private:
};
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.
Re: Destructor for Qtconcurrent::Exception?
Did you specify throw() for your destructor?
Re: Destructor for Qtconcurrent::Exception?
When I add the destructor
Code:
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
Code:
virtual ~SException() throw();
and
Code:
virtual ~SException() { throw(); }
?
Re: Destructor for Qtconcurrent::Exception?
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.
Re: Destructor for Qtconcurrent::Exception?
Thanks, I figured out what throw() does and I added an implementation to the destructor.