【发布时间】:2012-06-29 08:48:41
【问题描述】:
之前
考虑拥有一个类和一个全局函数:
例如,usefulfuncts.hpp
void dosome(int a, int b) throw (std::exception);
这是usefulfuncts.cpp
void dosome(int a, int b) throw (std::exception) {
//...
}
这是aclass.hpp
class aclass {
// Members...
friend void dosome(int a, int b) throw (std::exception);
// Members...
};
之后(我想要的)
好的!我想了解是否有必要每次都写 throw 子句。那么例如我可以这样做吗?
这是usefulfuncts.hpp
void dosome(int a, int b) throw (std::exception);
这是usefulfuncts.cpp
void dosome(int a, int b) { /* OMITTING IT! */
//...
}
这是aclass.hpp
class aclass {
// Members...
friend void dosome(int a, int b); /* OMITTING IT */
// Members...
};
这是对的吗?仅将其放在主要声明中?谢谢
【问题讨论】:
标签: c++ exception exception-handling declaration