gpt4 book ai didi

c++ - 我是否也仅在函数头或声明中指定异常类型? (C++)

转载 作者:太空宇宙 更新时间:2023-11-03 10:36:35 25 4
gpt4 key购买 nike

  SVector.H:

void pop_back() throw (underflow_error);

在我的 SVector.cpp 文件中,我是否也应该包含 throw (underflow_error) 部分?

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

void pop_back()
{
// implementation
}

谢谢。

最佳答案

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.

关于c++ - 我是否也仅在函数头或声明中指定异常类型? (C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2436908/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com