Default assignment operator= in c++ is a shallow copy?

前端 未结 8 2166
挽巷
挽巷 2020-12-14 05:42

Just a simple quick question which I couldn\'t find a solid answer to anywhere else. Is the default operator= just a shallow copy of all the class\' members on the right ha

8条回答
  •  爱一瞬间的悲伤
    2020-12-14 06:28

    No. operator= doesn't perform a copy at all. It's an assignment operator, not copy operator.

    The default assignment operator assigns each member.

提交回复
热议问题