Can I call a copy constructor explicitly?

前端 未结 6 1518
名媛妹妹
名媛妹妹 2021-02-02 12:50

I\'m a little confused as to the mechanics of the copy constructor. Correct me if I\'m wrong:

If a method takes a reference to an object as a parameter, and the class d

6条回答
  •  太阳男子
    2021-02-02 13:02

    Copy constructor is called only when passing by value, not by reference. By reference no copying is needed (this is part of what references are for!) so no copy constructor called.

提交回复
热议问题