1
SVector.H:
void pop_back() throw (underflow_error);
在我的SVector.cpp文件中,我是否也應該包含throw(underflow_error)部分?我是否僅在函數頭或聲明中指定了異常類型? (C++)
void pop_back() throw (underflow_error)
{
// implementation
}
OR
void pop_back()
{
// implementation
}
感謝。
就我個人而言,我討厭throw()語句。您可能對此感興趣:http://stackoverflow.com/questions/88573/should-i-use-an-exception-specifier-in-c – SoapBox 2010-03-13 01:41:38
您可能對Herb Sutter撰寫的這篇文章感興趣(http:// www.gotw.ca/publications/mill22.htm):道德#1:永遠不要寫出異常規範。道德#2:除了可能是空的,但如果我是你,我甚至會避免。 – 2010-03-13 05:31:55