looser throw specifier for in C++ looser throw specifier for in C++ xcode xcode

looser throw specifier for in C++


I assume that CPLAT has a base class? I'm also guessing that you did not put a throw specifier on CPLAT's destructor?

You can put throw(X) (where X is a comma-separated list of exceptions) at the end of a function's signature to indicate what exceptions it's allowed to throw. If you put throw() as the throw specifier, then it would indicate that no exceptions can be thrown from that function. It's fairly common to do this with destructors since you don't ever want a destructor to throw an exception.

A class that overrides a function which has a throw specifier cannot have a looser throw specifier (list more exceptions) than the function being overridden, since that would indicate that the derived class' function could violate the throw specifier of the base class' function. Not having a throw specifier means that any exception can be thrown from that function, so it's as loose as it can get.

In all likelihood, you need to add throw() to the end of the function signature of CPLAT's destructor.

Edit: By the way, I should probably add that you probably don't want to use throw specifiers (other than throw() on destructors) without really knowing that that's what you want. Unlike Java's checked exceptions, they're not caught at compile-time but rather terminate your program at runtime if violated. So, it's best not to use them unless you know what you're doing.


http://www.agapow.net/programming/cpp/looser-throw-specifier

Did you put throw() after the declaration of ~CP_Window() ?

Top link in google search "looser throw specifier" BTW.