Shallow vs. Deep Copies: Example
class atom {
private:
int x, y, z;
public:
x(); y(); z();
};
class molecule {
private:
int n;
atom *atom_array;
public:
// constructor
molecule(int natoms);
};
molecule::molecule(int natoms);
{
n = natoms;
atom_array = new atom[natoms];
}
molecule water(3);
Previous slide
Next slide
Back to first slide
View graphic version