What is the difference between overloading operator= and overloading the copy constructor?

后端 未结 3 560
我寻月下人不归
我寻月下人不归 2020-12-20 15:29

What is the difference between overloading the operator = in a class and the copy constructor?

In which context is each one called?

I m

3条回答
  •  轮回少年
    2020-12-20 16:10

    A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.

提交回复
热议问题