开发者

Do I specify exception types in just the function header or declarations as well? (C++)

  SVector.H:

  void pop_back() th开发者_如何学编程row (underflow_error);

In my SVector.cpp file, should I also include the throw (underflow_error) part as well?

void pop_back() throw (underflow_error)
{
    // implementation
}

OR

void pop_back()
{
    // implementation
}

Thanks.


15.4/2:

If any declaration of a function has an exception-specification, all declarations, including the definition and an explicit specialization, of that function shall have an exception-specification with the same set of type-ids.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜