In which situations is the C++ copy constructor called?

后端 未结 7 1673
梦毁少年i
梦毁少年i 2020-12-23 02:06

I know of the following situations in c++ where the copy constructor would be invoked:

  1. when an existing object is assigned an object of it own class

7条回答
  •  爱一瞬间的悲伤
    2020-12-23 02:58

    There are 3 situations in which the copy constructor is called: When we make copy of an object. When we pass an object as an argument by value to a method. When we return an object from a method by value.

    these are the only situations....i think...

提交回复
热议问题