How often do you implement the big three?

Posted by Neil Butterworth on Stack Overflow See other posts from Stack Overflow or by Neil Butterworth
Published on 2010-05-01T13:26:45Z Indexed on 2010/05/01 13:37 UTC
Read the original article Hit count: 225

Filed under:

I was just musing about the number of questions here that either are about the "big three" (copy constructor, assignment operator and destructor) or about problems caused by them not being implemented correctly, when it occurred to me that I could not remember the last time I had implemented them myself. A swift grep on my two most active projects indicate that I implement all three in only one class out of about 150.

That's not to say I don't implement/declare one or more of them - obviously base classes need a virtual destructor, and a large number of my classes forbid copying using the private copy ctor & assignment op idiom. But fully implemented, there is this single lonely class, which does some reference counting.

So I was wondering am I unusual in this? How often do you implement all three of these functions? Is there any pattern to the classes where you do implement them?

© Stack Overflow or respective owner

Related posts about c++