Dynamic memory and classes
class Vector { public: Vector(); Vector(Vector& other); Vector& operator=(Vector& other); ~Vector(); // ... }; foo(Vector a, Vector& b, Vector* c); // arbitrary function Assuming this Vector dynamically resizes itself (somehow), and that all methods are implemented correctly, what do each of the following do? Which lines invoke the no-argument constructor, copy constructor, destructor, and overloaded assignment operator? Which ones are legal and illegal? Why? Assume the statements are executed in order.
- Vector v();
- Vector* v2 = new Vector();
- Vector v3 = v;
- delete v2;
- v2 = &v;
- Vector v4 = v;
- v3 = *v2;
- Vector v5(v3);
- Vector* v6 = new Vector(v2);
- foo(v4, v5, v6);