Can a object be passed as value to the copy constructor

后端 未结 6 1941
清歌不尽
清歌不尽 2021-01-12 18:56

I have some confusion with this \"Can a object be passed as value to the copy constructor\" The compiler clearly rejects this, which means it is not possible. Can you help m

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-12 19:19

    Then why is it said that "Copy constructor will lead to recursive calls when pass by value is used."

    Because in order to pass an object to that copy constructor by value, you might need to copy-construct it first (because the passed-by-value parameter is a temporary copy of the original object passed).

提交回复
热议问题