catching polymorphic type 'class std::exception' by value [-Wcatch-value=]
Posted sageloris
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了catching polymorphic type 'class std::exception' by value [-Wcatch-value=]相关的知识,希望对你有一定的参考价值。
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=]的主要内容,如果未能解决你的问题,请参考以下文章
Rails 如何为多态关联填充“model_type”字段?