catching std::exception by reference?

后端 未结 4 1101
时光取名叫无心
时光取名叫无心 2021-02-01 05:30

I have a silly question. I read this article about std::exception http://www.cplusplus.com/doc/tutorial/exceptions/

On catch (exception& e), it says:

4条回答
  •  自闭症患者
    2021-02-01 06:10

    No the & has absolutely no bearing on the polymorphic nature of exception handlers. Their wording is very poor, it does seem to indicate that the & is somehow responsible. This is not the case. You are correct, & just passes by reference which is a tad more efficient.

    Also as a general rule, you should really try to avoid cplusplus.com.

    Updated link: What's wrong with cplusplus.com

提交回复
热议问题