Is this good code? (copy constructor and assignment operator )

前端 未结 6 1218
感动是毒
感动是毒 2020-12-08 12:07

For one reason or another, I\'m forced to provide both a copy constructor and an operator= for my class. I thought I didn\'t need operator= if I defined a copy

6条回答
  •  Happy的楠姐
    2020-12-08 12:56

    I think you run into issues if your operator= ever becomes virtual.

    I would recommend writing a function (maybe static) that does the copy then have the copy-constructor and operator= call that function instead.

提交回复
热议问题