Short copy:
Some copy members may relate to the same items as the original:
class X
{
private:
int i;
int *pi;
public:
X()
: pi(new int)
{ }
X(const X& copy) // <-- copy ctor
: i(copy.i), pi(copy.pi)
{ }
};
The pi member of the original and duplicated X objects will both point to the identical int in this case.
Deep copy:
The whole original cast has been cloned (recursively, if necessary).
There are no shared objects:
class X
{
private:
int i;
int *pi;
public:
X()
: pi(new int)
{ }
X(const X& copy) // <-- copy ctor
: i(copy.i), pi(new int(*copy.pi)) // <-- note this line in particular!
{ }
};
In this case, the pi member of the original and copied X objects will point to separate int objects with the same value.