Is it good practice to generally make heavyweight classes non-copyable?

Posted by Emile Cormier on Stack Overflow See other posts from Stack Overflow or by Emile Cormier
Published on 2010-03-19T15:58:43Z Indexed on 2010/03/19 16:01 UTC
Read the original article Hit count: 305

I have a Shape class containing potentially many vertices, and I was contemplating making copy-constructor/copy-assignment private to prevent accidental needless copying of my heavyweight class (for example, passing by value instead of by reference).

To make a copy of Shape, one would have to deliberately call a "clone" or "duplicate" method.

Is this good practice? I wonder why STL containers don't use this approach, as I rarely want to pass them by value.

© Stack Overflow or respective owner

Related posts about c++

Related posts about best-practices