|
-
June 19th, 2013, 10:08 AM
#1
A question regarding exception specification
If a class inherits from another and overrides a virtual function, then the exception-specification for the overridden function must be at least as restrictive. What does it mean? Here is an example,
Code:
class B
{
public:
virtual void foo() throw (int)
{
}
};
class D: public B
{
public:
virtual void foo() throw (double)
{
}
};
It compiles fine. In the derived class, virtual function foo throws double and in the base class, foo throws int. So double is supposed to be at least as restrictive? Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|