Copy constructor with pointers

前端 未结 9 1125
清歌不尽
清歌不尽 2020-12-14 10:08

I have recently discovered that when I have pointers within a class, I need to specify a Copy constructor.

To learn that, I have made the following simple code. It c

9条回答
  •  佛祖请我去吃肉
    2020-12-14 10:28

    I have recently discovered that when I have pointers within a class, I need to specify a Copy constructor

    More often than not it is a good idea to simply disable it by declaring it (and the assigment operator) private and not implementing it.

提交回复
热议问题