标签: c++ exception std
我需要抛出std :: exeption,如果rad是整数,如何抛出?
void Circle::setRad(double rad) { if (rad < 0) { throw(std::exception ); } radius = rad; }
答案 0 :(得分:1)
通常,您应该抛出派生类之一:
throw std::invalid_argument("radius must be nonnegative");