标签:type pre span amp exce test 应该 person style
class Person{ public: Person(){ mAge = 0; } void setAge(int age){ if(age < 0 || age > 100){ throw out_of_range("年龄应该在0-100之间!"); } this->mAge = age; } public: int mAge; }; void test01(){ Person p; try{ p.setAge(1024); }catch(out_of_range& e){//此处报错 cout << e.what() << endl; } }
gcc编译报错catching polymorphic type ‘class std::exception‘ by value [-Wcatch-value=];
catching polymorphic type 'class std::exception' by value [-Wcatch-value=]
标签:type pre span amp exce test 应该 person style
原文地址:https://www.cnblogs.com/sageloris/p/11448201.html