






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







template
and then when Vec is referred to it must be
Vec
template
Vec
with int replacing T. This also compiles the default constructor for Vec
Vec
the template class declaration is compiled again, this time with double replacing T instead of int. Again, however, only the member functions used are compiled.
Now, looking inside the Vec
Drawing a picture, which we will do in class, will help clarify this, especially the distinction between m size and m alloc.
Vec
is an iterator type defined by the Vec
Vec
is the size type, defined here as an unsigned int.
template
In other words, it would construct each member variable from the corresponding member variable of v.
Suppose we used the default version of the assignment operator and copy constructor in our Vec
Vec
Explain why this happens by drawing a picture of the memory of both u and v.
Write the private member function copy.
v1 = v2;
are translated by the compiler as
v1.operator=(v2);
v1 = v2 = v3;
are translated by the compiler as
v1.operator=(v2.operator=(v3));
The implementation of an assignment operator usually takes on a very spe- cific form, as illustrated for Vec
push_back( T const& x )