2

让我们A成为重载类operator= 如果我按值调用具有参数A的函数,重载会operator=被调用吗?

4

1 回答 1

6

No its assignment operator won't be called.
The copy constructor will be called.

That is the purpose of copy constructor, to create copies of the type by taking in an object of the same type. Pass by value is the typical case where copy constructor is always called.

于 2012-04-15T07:59:35.797 回答