C++ Programming

What is a bit copy?

User Avatar
Wiki User
January 13, 2010 5:58PM

A bit copy of an object is an exact, bit-by-bit, copy of that object. The default copy constructor generated by the compiler makes a bit copy.

This is potentially a problem if the object contains pointers to other objects...

A bit copy of a pointer copies the pointer, but not its data. This means that you have two pointers pointing at the same object in memory. If you delete one of them, the other becomes invalid, and this can (usually does) cause corruption.

If an object contains a pointer, the object's copy constructor should provide for proper allocation and copying of any pointed to objects within that object.