the array is simply pointer variable to block of memorythe actual array size must be maintained separately by the programmer the block of memory can be allocated via new[but then must be freed via delete[ the block of memory cannot be resized (but newpresumably larger block can be obtained and initialized with the old blockand then the old block can be freedto avoid ambiguities with the library classwe will name our class template vector before examining the vector codewe outline the main details the vector will maintain the primitive array (via pointer variable to the block of allocated memory)the array capacityand the current number of items stored in the vector the vector will implement the big-five to provide deep-copy semantics for the copy constructor and operator=and will provide destructor to reclaim the primitive array it will also implement ++ move semantics the vector will provide resize routine that will change (generally to larger numberthe size of the vector and reserve routine that will change (generally to larger numberthe capacity of the vector the capacity is changed by obtaining new block of memory for the primitive arraycopying the old block into the new blockand reclaiming the old block the vector will provide an implementation of operator[(as mentioned in section operator[is typically implemented with both an accessor and mutator version the vector will provide basic routinessuch as sizeemptyclear (which are typically one-liners)backpop_backand push_back the push_back routine will call reserve if the size and capacity are same the vector will provide support for the nested types iterator and const_iteratorand associated begin and end methods figure and figure show the vector class like its stl counterpartthere is limited error checking later we will briefly discuss how error checking can be provided as shown on lines to the vector stores the sizecapacityand primitive array as its data members the constructor at lines to allows the user to specify an initial sizewhich defaults to zero it then initializes the data memberswith the capacity slightly larger than the sizeso few push_backs can be performed without changing the capacity the copy constructorshown at lines to makes new vector and can then be used by casual implementation of operatorthat uses the standard idiom of swapping in copy this idiom works only if swapping is done by movingwhich itself requires the implementation of the move constructor and move operatorshown at lines to againthese use very standard idioms implementation of the copy assignment operatorusing copy constructor and swapwhile simpleis certainly not the most efficient methodespecially in the case where both vectors have the same size in that special casewhich can be tested forit can be more efficient to simply copy each element one by one using object' operator