There are thus three primary ways in which passing an object to a function or using that object to invoke a virtual function differs from throwing the object as an exception. First, exception objects are always copied; when caught by value, they are copied twice. Objects passed to function parameters need not be copied at all. Second, objects thrown as exceptions are subject to fewer forms of type conversion than are objects passed to functions. Finally, catch
clauses are examined in the order in which they appear in the source code, and the first one that can succeed is selected for execution. When an object is used to invoke a virtual function, the function selected is the one that provides the best match for the type of the object, even if it's not the first one listed in the source code.
Item 13:Catch exceptions by reference.(More Effective C++)
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
从C 向C++13——模板
从C向C++13——模板
类模板 函数模板 数组 -
51c视觉~合集13视觉AI
-
《More Effective C++ 》笔记
条款10 防止构造函数里的资源泄露条款20 协助编译器实现返回值优化条款22 考虑使用op=来取代单独的op运算符条款26 限制类对象的个数条款27 要求或禁止对象分配在堆上
构造函数 类对象 编译器 运算符 javascript