Rule of Three in C++

后端 未结 3 1342
一生所求
一生所求 2020-12-07 03:43

I\'ve read that The Rule of Three, What is The Rule of Three? is summarized as follows:

If you need to explicitly declare either the destructor, copy

3条回答
  •  误落风尘
    2020-12-07 04:18

    I am absolutely certain that there is no usage in the application of a copy constructor, i.e., usage of the type Class c(..); Class d(c)

    Are you aware that the following code

    Foo c;
    Foo b = c;
    

    invokes the copy constructor and NOT the assignment operator? I'd implement the copy constructor just to be safe.

提交回复
热议问题