Questions tagged «specifier»

14
我应该在C ++中使用异常说明符吗?
在C ++中,可以通过使用异常说明符来指定一个函数可以抛出异常,也可以不抛出异常。例如: void foo() throw(); // guaranteed not to throw an exception void bar() throw(int); // may throw an exception of type int void baz() throw(...); // may throw an exception of some unspecified type 由于以下原因,我对实际使用它们表示怀疑: 编译器实际上并没有以任何严格的方式强制执行异常说明符,因此好处并不大。理想情况下,您希望获得一个编译错误。 如果函数违反异常说明符,我认为标准行为是终止程序。 在VS.Net中,它将throw(X)视为throw(...),因此对标准的遵循性不强。 您认为应该使用异常说明符吗? 请回答“是”或“否”,并提供一些理由来证明您的回答合理。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.